

























The Rust team is happy to announce the latest version of Rust, 1.7. Rust is a systems programming language focused on safety, speed, and concurrency.
As always, you can install Rust 1.7 from the appropriate page on our website, and check out the detailed release notes for 1.7 on GitHub. About 1300 patches were landed in this release.
This release is primarily about library features. While we have several language features cooking for future releases, the timeframe in which 1.7 was developed included the holidays, which means less time for commenting on GitHub and more time for spending with loved ones.
About 40 library functions and methods are now stable in 1.7. One of the
largest APIs stabilized was support for custom hash algorithms in the standard
library’s HashMap<K, V> type. Previously all hash maps would use SipHash as
the hashing algorithm, which provides protection against DOS attacks by
default. SipHash, however, is not very fast at hashing small keys. As shown,
however, the FNV hash algorithm is much faster for these size of inputs. This
means that by switching hash algorithms for types like HashMap<usize, V>
there can be a significant speedup so long as the loss of DOS protection is
acceptable.
To see this in action, you can check out the fnv crate on crates.io and
create a HashMap via:
extern crate fnv;
use std::collections::HashMap;
use std::hash::BuildHasherDefault;
use fnv::FnvHasher;
type MyHasher = BuildHasherDefault<FnvHasher>;
fn main() {
let mut map: HashMap<_, _, MyHasher> = HashMap::default();
map.insert(1, "Hello");
map.insert(2, ", world!");
println!("{:?}", map);
}
Note that most of the time you don’t even need to specify the hasher as type
inference will take care of it, so HashMap::default() should be all you need
to get up to 2x faster hashes. It’s also worth pointing out that Hash trait
is agnostic to the hashing algorithm used, so no changes are needed to the
types being inserted into hash maps to reap the benefits!
Other notable improvements include:
<[T]>::clone_from_slice(), an efficient way to copy the data from one slice
and put it into another slice.Ipv4Addr and Ipv6Addr, such as is_loopback(),
which returns true or false if the address is a loopback address according to
RFC 6890.CString, used for FFI.See the detailed release notes for more.
There were a few small updates to Cargo:
cargo rustc subcommand, which allows specifying
profiles to pull in dev-dependencies during testing and such.We had 144 individuals contribute to 1.7. Thank you so much!
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。