@moonbolt ident!() means a macro call. !expr is a negation.

@codingquark @schrieveslaach Pipe behavior is mostly implemented by the shell/libc/OS, so not really a language-specific issue. The only difference is that Rust's standard library defaults to handling Broken Pipe signal as a regular I/O error instead of killing the process. But Rust does error handling pretty well generally.

@zatnosk I'm surprised that there isn't an automated block list exchange protocol yet.

@reconbot People sometimes write Arc::clone(&a) instead of a.clone() to make it clear this one is cheap.

@reconbot Yeah, clone gives you an owned value. Owned vs borrowed distinction doesn't exist explicitly in most other languages, but it's absolutely essential to "get" ownership to be proficient in Rust.

@reconbot If you need references that are less close to the metal, wrap stuff in Arc, e.g. Box<str>. This gives you references more like in GC languages, which can live forever and don't get invalidated by implementation details.

@reconbot There is no solution. The second insertion may need to reallocate the hashmap, which invalidates all previous references.

For a single insert you can match on Entry enum. For multiple inserts, inserts-then-gets are the best you can do with std HashMap.

hashbrown has a raw_entry API for memoizing hash values for some performance.

All Labradors are "Chocolate" Labradors! Some of them are just white chocolate.

Kornel boosted

Wanna feel old? We’re closer to the Y2K38 bug than to the Y2K bug.

My first impressions of HP G2 : frustrating.

It's a very nice screen, mediocre controllers, and atrocious buggy WMR software that stops me from using it for more than 10 minutes without bugs, lags, and glitches.

/crates-io will (eventually) have a new registry protocol that is more scalable, and faster for fresh installs like CI or Docker:

github.com/rust-lang/rfcs/pull

@Apitronics To cross compile you need 1) cross-compiler 2) cross-linker 3) system libraries for the target OS.

Rust has 1 already done very well, will have 2 in the future, but providing 3 is not planned.

Kornel boosted

Big news in cryptography! Sequoia PGP v1.0 has been released. This is an alternative implementation of OpenPGP (Pretty Good Privacy) standard, as compared to GnuPG. Besides being written in #rustlang, it takes a library-first approach. sequoia-pgp.org/blog/2020/12/1

@reconbot Referencing the map wouldn't work because you couldn't add items to the map while referencing items already in it. That's not even a theoretical limitation, but a real use-after-free bug risk.

As for immutability, Rust has "interior mutability" which lets you mutate immutable things thanks to runtime checks, e.g. Mutex<T> is an immutable container with mutable contents.

@reconbot While references exist, the map has to be immutable and unmovable to make it impossible to invalidate the references. So that won't work, unfortunately.

@reconbot `&Something` can't exist on its own. It's not an object you can freely use, but a temporary view into something else. For every instance of &X there has to be a permanently stored immutable owned counterpart already existing in an outer scope. That's is as limiting as it sounds, so typical Rust programs limit usage of temporary borrows only to function-local variables and very rarely anything else.

@reconbot Arc is a shared reference that can own its content. Arc<Mutex> (or its single-threaded equivalent Rc<ReCell>) is a common pattern for shared mutable data.

Show older
Mastodon

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!