Elektrine lite

← Feed

@Mara@hachyderm.io

Post #2227699

2025-11-19 07:36 UTC

(That the name "or_panic" would have been better isn't much of a hot take, but adding "or_panic()" now and deprecating "unwrap()" would likely be controversial.)

Replies (11)

  • @Mara@hachyderm.io Idea: doc alias?

    Open ##2227702

  • @pj@donotsta.re 2025-11-19 07:38

    I think it would be fine but the deprecation lint would have to start being enforced in next edition and I don't think .unwrap*() could be truly deprecated for the next few editions @Mara@hachyderm.io

    Open ##2227703

  • @beeb@hachyderm.io 2025-11-19 07:55

    @Mara@hachyderm.io I have done it in some projects via a trait in the prelude and enabling the lints to forbid unwrap: https://github.com/beeb/awsbck/blob/main/src%2Fprelude.rs

    Open ##2227705

  • @KingmaYpe@mastodon.green 2025-11-19 09:10

    @Mara@hachyderm.io I'm looking forward to the next editions: one to deprecate, one to remove. That would also soften the controversy.

    Open ##2227706

  • @snaggen@mastodonsweden.se 2025-11-19 09:13

    @Mara@hachyderm.io I don't see why this would be controversial? It would make things much more clear and consistent. Adding this as a deprecation, with an auto fix upon removal would be great.

    Open ##2227707

  • @Mara@hachyderm.io or make unwrap -> unwrap_or_panic unwrap_or_default -> unwrap But this probably crashes with legacy code.

    Open ##2227708

  • @chrisdenton@hachyderm.io 2025-11-19 14:31

    @Mara@hachyderm.io ACP time?

    Open ##2227709

  • @mmastrac@hachyderm.io 2025-11-19 16:42

    @Mara@hachyderm.io This could totally be done if done very slowly IMO. eg: Start by adding a feature that makes deprecation warnings show only once for an entire class of function per codebase, have that turned off by default, allow it to be disabled per-crate in Cargo.toml. Turn it on in nightlies for a bit, wait a few months. Patches should start to flow into upstream crates to fix those warnings. Wait for the top N% of crates on crates.io to be fixed, roll it out to beta and then stable. Plan on doing this over 2-3 years.

    Open ##2227710

  • @slatian@pleroma.envs.net 2025-11-19 18:52

    @Mara@hachyderm.io Deprecating unwrap would be something for the next rust edition? I’d happily adapt some old code.

    Open ##2227712

  • @aismallard@woem.space 2025-11-19 19:00

    @Mara@hachyderm.io Probably but that doesn’t mean we still shouldn’t do it. Though it would probably stay #[deprecated] for an extremely long time and would only actually get removed in an edition change.

    Open ##2227713

  • @bshn@hachyderm.io 2025-11-20 13:27

    @Mara@hachyderm.io I think we should not solve the problems of people who didn't read the Book 😁 If comment seriously, not sure that changing the name will help here, as this functionality so basic, that no developer would use it without understanding the consequences.

    Open ##2227714