@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.
@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.
@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.
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. https://sequoia-pgp.org/blog/2020/12/16/202012-1.0/
@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.