3 ms·
> Rust is so easy to compose reliably that even the stdlib itself does not shy from pulling dependencies from crates.io. The standard library depends on extern
by schemescape 4y ago
> Rust is so easy to compose reliably that even the stdlib itself does not shy from pulling dependencies from crates.io.
The standard library depends on external crates?
(Edit to remove that last part since it seems irrelevant.)
- iudqnolq 4y agoI just peaked at the crates.io dependencies in the standard library. There's three dependencies to high-quality libraries in the rust-lang GitHub organization: a macro to make conditional compilation easier (cfg_if), a port of Google's SwissTable hashmap library (hashbrown), and bindings to libc. These all have maintainers in common with the standard library. The rust standard library hashmap is (zero cost) wrapper around a hashbrown hashmap with a subset of hashbrown's methods. cfg_if is probably used just for the convenience. I guess they're not ready to commit to stabilizing that macro in the standard library for some reason. libc was originally autogenerated from the c header files, but if I recall correctly updating it involves a bunch of annoying manual processes necessary to ensure perfect compatibility. It's obvious used in the implementation of standard library features. Then there's a handful of dependenencies for the optional but enabled-by-default backtrace feature like a symbol demangler and a zlib encoder/decoder. I'm not familiar with their quality, but I don't think it's as excellent as the other dependencies.
- lifthrasiir 4y ago> The standard library depends on external crates? Yes: https://github.com/rust-lang/rust/blob/478cbb42b730ba4739351b72ce2aa928e78e2f81/library/std/Cargo.toml#L12C15-L23 https://github.com/rust-lang/rust/blob/478cbb42b730ba4739351... Of course it is not "some random" crate; all of them is either in the same repository (when `path` is used) or in other repositories under the `rust-lang` organization with well-known contributors. But the latter is conceptually no more special than other repositories, so Cargo works same.
- schemescape 4y agoThanks! I was interpreting the comment to mean code that wasn’t in the standard library repository, which surprised me.
- iudqnolq 4y agoYou interpreted it right. There are dependencies on other repositories in the rust-lang GitHub organization. The optional dependencies for the backtrace feature include libraries outside the rust-lang GitHub org. https://news.ycombinator.com/item?id=35350600 https://news.ycombinator.com/item?id=35350600
- schemescape 4y agoThanks! I did see your helpful comment, but I only replied to the other one :)