`std::hashmap::HashMap.insert_or_update_with()` is basically the opposite
of `find_or_insert_with()`. It inserts a given key-value pair if the key
does not already exist, or replaces the existing value with the output
of the passed function if it does.
This is useful because replicating this with existing functionality is awkward, especially with the current borrow-checker. In my own project I have code that looks like
if match map.find_mut(&key) {
None => { true }
Some(x) => { *x += 1; false }
} {
map.insert(key, 0);
}
and it took several iterations to make it look this good. The new function turns this into
map.insert_or_update_with(key, 0, |_,x| *x += 1);
Add new private hashmap function
fn mangle(&mut self,
k: K,
not_found: &fn(&K) -> V,
found: &fn(&K, &mut V)) -> uint
Rewrite find_or_insert() and find_or_insert_with() on top of mangle().
Also take the opportunity to change the return type of find_or_insert()
and find_or_insert_with() to &'a mut V. This fixes#6394.
Closes#5090 by using the excellent new generic deriving code
Promotes the unreachable code attribute to a lint attribute (instead of always being a warning)
Fixes some edge cases when creating hashmaps/hashsets and also when consuming them. (fixes#5998)
Fix a laundry list of warnings involving unused imports that glutted
up compilation output. There are more, but there seems to be some
false positives (where 'remedy' appears to break the build), but this
particular set of fixes seems safe.
Fix a laundry list of warnings involving unused imports that glutted
up compilation output. There are more, but there seems to be some
false positives (where 'remedy' appears to break the build), but this
particular set of fixes seems safe.
Calls to the libc versions of fmin and fmax were relatively slow (perhaps because they could not be inlined?). This pull request provides f32 and f64 with fmin and fmax written in Rust, and shows a significant speed increase on my system; I used https://github.com/thiez/rustray as my benchmark, with --opt-level 3 it brings the ray-tracing time down from 10.8 seconds to about 9.2, which seemed significant to me.
r?
This works with pandoc linked against highlighting-kate >= 0.5.3.8. It seems to just be a no-op with earlier versions, because I successfully ran this through `try`.
This also fixes some consistency issues (like making `Example`/`Examples` always a header and always using three tildes).
There were several old `#[doc(hidden)]` attributes in libstd and
libextra, left over from when rustdoc didn't hide private
definitions, tagged with `FIXME #3538`.
Since #3538 is now closed, I removed the `#[doc(hidden)]` attributes
as well as the FIXMEs, but I left `#[doc(hidden)]` in
libstd/task/spawn.rs and libstd/task/rt.rs since those two are
apparently `pub`, as well as in libextra/std.rc since std/extra is
`pub`.