Rustaceans at the border
Rustaceans at the border
Posted Apr 15, 2022 0:05 UTC (Fri) by tialaramex (subscriber, #21167)In reply to: Rustaceans at the border by ssokolow
Parent article: Rustaceans at the border
So e.g. suppose you've got a slice (maybe an array, but however you got it, some contiguous memory) of Things and you'd like to sort them. In C without the standard library you're out of luck, code it yourself, but in Rust lacking std only means you don't have a nice stable allocating merge sort, you do still get a perfectly usable (albeit not always trivially what you needed) in-place unstable sort.
https://rust-for-linux.github.io/docs/core/primitive.slice.html#method.sort_unstable
When C was invented such things would be too heavy, but today Rust's compiler and linker are certainly smart enough that if you never actually perform sort_unstable the code to implement it is omitted from your binary so the "price" of Rust's more comprehensive library is only that the documentation is a little larger and for that price you avoid the unsettlingly common (even in Linux) discovery that six people have re-implemented some useful idea, meaning the kernel carries not one but six copies of the code, and worse at least one of them is actually faulty.
