Rust versions / 1.28
Rust release · Aug 2, 2018
Rust 1.28: what's new, what was stabilized
Short answerRust 1.28 was released on Aug 2, 2018: 29 newly stable APIs (Iterator::step_by, Path::ancestors, SystemTime::UNIX_EPOCH, alloc::GlobalAlloc, ...); 1 compatibility note that can affect existing code.
← Rust 1.27All versionsRust 1.29 →
29 APIs stabilized
Iterator::step_by, Path::ancestors, SystemTime::UNIX_EPOCH, alloc::GlobalAlloc, alloc::Layout, alloc::LayoutErr, alloc::System, alloc::alloc, alloc::alloc_zeroed, alloc::dealloc, alloc::realloc, alloc::handle_alloc_error, btree_map::Entry::or_default, fmt::Alignment, hash_map::Entry::or_default, iter::repeat_with, num::NonZeroUsize, num::NonZeroU128, num::NonZeroU16, num::NonZeroU32, num::NonZeroU64, num::NonZeroU8, ops::RangeBounds, slice::SliceIndex, slice::from_mut, slice::from_ref, {Any + Send + Sync}::downcast_mut, {Any + Send + Sync}::downcast_ref, {Any + Send + Sync}::is
Can it break my build?
The release lists these compatibility notes. Most only affect rare code, but read them before you raise your toolchain in CI:
- [Rust will consider trait objects with duplicated constraints to be the same
Use it
rustup update stable # get the newest release
rustup install 1.28 # or exactly this one
rustup override set 1.28 # pin a project to itTo require at least this version from users of your crate, set rust-version = "1.28" under [package] in Cargo.toml. Cargo then refuses to build it on older compilers with a clear message, and with resolver 3 (the default on the 2024 edition, Rust 1.85+) it also prefers dependency versions that support it.
Full release notes
Language
- [The
#[repr(transparent)]attribute is now stable.][51562] This attribute allows a Rust newtype wrapper (struct NewType<T>(T);) to be represented as the inner type across Foreign Function Interface (FFI) boundaries. - [The keywords
pure,sizeof,alignof, andoffsetofhave been unreserved and can now be used as identifiers.][51196] - [The
GlobalAlloctrait and#[global_allocator]attribute are now stable.][51241] This will allow users to specify a global allocator for their program. - [Unit test functions marked with the
#[test]attribute can now returnResult<(), E: Debug>in addition to().][51298] - [The
lifetimespecifier formacro_rules!is now stable.][50385] This allows macros to easily target lifetimes.
Compiler
- [The
sandzoptimisation levels are now stable.][50265] These optimisations prioritise making smaller binary sizes.zis the same asswith the exception that it does not vectorise loops, which typically results in an even smaller binary. - [The short error format is now stable.][49546] Specified with
--error-format=shortthis option will provide a more compressed output of rust error messages. - [Added a lint warning when you have duplicated
macro_exports.][50143] - [Reduced the number of allocations in the macro parser.][50855] This can improve compile times of macro heavy crates on average by 5%.
Libraries
- [Implemented
Defaultfor&mut str.][51306] - [Implemented
From<bool>for all integer and unsigned number types.][50554] - [Implemented
Extendfor().][50234] - [The
Debugimplementation oftime::Durationshould now be more easily human readable.][50364] Previously aDurationof one second would printed asDuration { secs: 1, nanos: 0 }and will now be printed as1s. - [Implemented
From<&String>forCow<str>,From<&Vec<T>>forCow<[T]>,From<Cow<CStr>>forCString,From<CString>, From<CStr>, From<&CString>forCow<CStr>,From<OsString>, From<OsStr>, From<&OsString>forCow<OsStr>,From<&PathBuf>forCow<Path>, andFrom<Cow<Path>>forPathBuf.][50170] - [Implemented
ShlandShrforWrapping<u128>andWrapping<i128>.][50465] - [
DirEntry::metadatanow usesfstatatinstead oflstatwhen possible.][51050] This can provide up to a 40% speed increase. - [Improved error messages when using
format!.][50610]
Stabilized APIs
- [
Iterator::step_by] - [
Path::ancestors] - [
SystemTime::UNIX_EPOCH] - [
alloc::GlobalAlloc] - [
alloc::Layout] - [
alloc::LayoutErr] - [
alloc::System] - [
alloc::alloc] - [
alloc::alloc_zeroed] - [
alloc::dealloc] - [
alloc::realloc] - [
alloc::handle_alloc_error] - [
btree_map::Entry::or_default] - [
fmt::Alignment] - [
hash_map::Entry::or_default] - [
iter::repeat_with] - [
num::NonZeroUsize] - [
num::NonZeroU128] - [
num::NonZeroU16] - [
num::NonZeroU32] - [
num::NonZeroU64] - [
num::NonZeroU8] - [
ops::RangeBounds] - [
slice::SliceIndex] - [
slice::from_mut] - [
slice::from_ref] - [
{Any + Send + Sync}::downcast_mut] - [
{Any + Send + Sync}::downcast_ref] - [
{Any + Send + Sync}::is]
Cargo
- [Cargo will now no longer allow you to publish crates with build scripts that modify the
srcdirectory.][cargo/5584] Thesrcdirectory in a crate should be considered to be immutable.
Misc
- [The
suggestion_applicabilityfield inrustc's json output is now stable.][50486] This will allow dev tools to check whether a code suggestion would apply to them.
Compatibility Notes
- Rust will consider trait objects with duplicated constraints to be the same type as without the duplicated constraint. For example the below code will now fail to compile. ```rust trait Trait {}
impl Trait + Send { fn test(&self) { println!("one"); } //~ ERROR duplicate definitions with name test }
impl Trait + Send + Send { fn test(&self) { println!("two"); } } ```
Release notes from the Rust project's RELEASES.md (MIT or Apache-2.0); summaries above are ours.
Up next
Next releaseRust 1.29Released Sep 13, 2018.Read it next →Also worth your time
Did this answer your question?