Cookies op Tweakers

Tweakers maakt gebruik van cookies, onder andere om de website te analyseren, het gebruiksgemak te vergroten en advertenties te tonen. Door gebruik te maken van deze website, of door op 'Ga verder' te klikken, geef je toestemming voor het gebruik van cookies. Wil je meer informatie over cookies en hoe ze worden gebruikt, bekijk dan ons cookiebeleid.

Meer informatie

Software-update: Rust 1.38.0

Rust is een programmeertaal bedacht door Graydon Hoare en oorspronkelijk ontwikkeld door Mozilla. Het is deels geïnspireerd op de programmeertaal C, maar kent syntactische en semantische verschillen. Het focust op veiligheid en beoogt moderne computersystemen efficiënter te benutten. Het wordt ingezet door onder ander Cloudflare, OVH, Mozilla, Deliveroo, Coursera, AppSignal en Threema. Versie 1.38.0 is onlangs uitgebracht met de volgende aankondiging:

What's in 1.38.0 stable

The highlight of this release is pipelined compilation.

Pipelined compilation
To compile a crate, the compiler doesn't need the dependencies to be fully built. Instead, it just needs their "metadata" (i.e. the list of types, dependencies, exports...). This metadata is produced early in the compilation process. Starting with Rust 1.38.0, Cargo will take advantage of this by automatically starting to build dependent crates as soon as metadata is ready.

While the change doesn't have any effect on builds for a single crate, during testing we got reports of 10-20% compilation speed increases for optimized, clean builds of some crate graphs. Other ones did not improve much, and the speedup depends on the hardware running the build, so your mileage might vary. No code changes are needed to benefit from this.

Linting some incorrect uses of mem::{uninitialized, zeroed}
As previously announced, std::mem::uninitialized is essentially impossible to use safely. Instead, MaybeUninit<T> should be used.

We have not yet deprecated mem::uninitialized; this will be done in a future release. Starting in 1.38.0, however, rustc will provide a lint for a narrow class of incorrect initializations using mem::uninitialized or mem::zeroed.

It is undefined behavior for some types, such as &T and Box<T>, to ever contain an all-0 bit pattern, because they represent pointer-like objects that cannot be null. It is therefore an error to use mem::uninitialized or mem::zeroed to initialize one of these types, so the new lint will attempt to warn whenever one of those functions is used to initialize one of them, either directly or as a member of a larger struct. The check is recursive, so the following code will emit a warning:
struct Wrap<T>(T); struct Outer(Wrap<Wrap<Wrap<Box<i32>>>>); struct CannotBeZero { outer: Outer, foo: i32, bar: f32 } ... let bad_value: CannotBeZero = unsafe { std::mem::uninitialized() };
Astute readers may note that Rust has more types that cannot be zero, notably NonNull<T> and NonZero<T>. For now, initialization of these structs with mem::uninitialized or mem::zeroed is not linted against.

These checks do not cover all cases of unsound use of mem::uninitialized or mem::zeroed, they merely help identify code that is definitely wrong. All code should still be moved to use MaybeUninit instead.

#[deprecated] macros
The #[deprecated] attribute, first introduced in Rust 1.9.0, allows crate authors to notify their users an item of their crate is deprecated and will be removed in a future release. Rust 1.38.0 extends the attribute, allowing it to be applied to macros as well.


For debugging, it is sometimes useful to get the name of a type. For instance, in generic code, you may want to see, at run-time, what concrete types a function's type parameters has been instantiated with. This can now be done using std::any::type_name:
fn gen_value<T: Default>() -> T { println!("Initializing an instance of {}", std::any::type_name::<T>()); Default::default() } fn main() { let _: i32 = gen_value(); let _: String = gen_value(); }
This prints:
Initializing an instance of i32 Initializing an instance of alloc::string::String
Like all standard library functions intended only for debugging, the exact contents and format of the string are not guaranteed. The value returned is only a best-effort description of the type; multiple types may share the same type_name value, and the value may change in future compiler releases.

Library changes
  • slice::{concat, connect, join} now accepts &[T] in addition to &T.
  • *const T and *mut T now implement marker::Unpin.
  • Arc<[T]> and Rc<[T]> now implement FromIterator<T>.
  • iter::{StepBy, Peekable, Take} now implement DoubleEndedIterator.
Additionally, these functions have been stabilized:
  • <*const T>::cast and <*mut T>::cast
  • Duration::as_secs_f32 and Duration::as_secs_f64
  • Duration::div_f32 and Duration::div_f64
  • Duration::from_secs_f32 and Duration::from_secs_f64
  • Duration::mul_f32 and Duration::mul_f64
  • Euclidean remainder and division operations -- div_euclid, rem_euclid -- for all integer primitives. checked, overflowing, and wrapping versions are also available.
Other changes
There are other changes in the Rust 1.38 release: check out what changed in Rust, Cargo, and Clippy.

A Previous version of this post mistakenly marked these functions as stable. They are not yet stable. Duration::div_duration_f32 and Duration::div_duration_f64.

Contributors to 1.38.0
Many people came together to create Rust 1.38.0. We couldn't have done it without all of you. Thanks!
Versienummer 1.38.0
Releasestatus Final
Website The Rust Programming Language Blog
Licentietype Voorwaarden (GNU/BSD/etc.)

Door Japke Rosink



Reacties (3)

Wijzig sortering

Apple iPhone 11 Nintendo Switch Lite LG OLED C9 Google Pixel 4 FIFA 20 Samsung Galaxy S10 Sony PlayStation 5 Apple

'14 '15 '16 '17 2018

Tweakers vormt samen met Hardware Info, AutoTrack,, Nationale Vacaturebank, Intermediair en Independer DPG Online Services B.V.
Alle rechten voorbehouden © 1998 - 2019 Hosting door True