Rust 1.41.0 release: new guarantees for Box in FFI, improvements in cargo install, easing restrictions for traits

The Rust team is pleased to announce the release of a new version, 1.41.0. Rust is a programming language that allows everyone to create reliable and efficient software.


If you installed the previous version of Rust using tools rustup, then to upgrade to version 1.41.0 you just need to run the following command:


rustup update stable

If you haven’t already installed it rustup, you can install it from the corresponding page of our website, as well as see detailed release notes for GitHub.


What is included in the stable version 1.41.0


The main innovations of Rust 1.41.0 are the easing of restrictions on the implementation of traits, improvements cargo install, the new file format is Cargo.lockmore friendly to work with git, and new guarantees for those Box<T>associated with FFI. See release notes for more information.


Easing restrictions on the implementation of traits


, , Rust (orphan rule). , , , , .. . , .


Rust 1.41.0 , . , BetterVec<T>, Vec<T> . :


impl<T> From<BetterVec<T>> for Vec<T> {
    // ...
}

… :


impl<T> ForeignTrait<LocalType> for ForeignType<T> {
    // ...
}

Rust 1.40.0 impl , From Vec , . , newtype, .


From Vec , ( From) . , Rust 1.41.0 impl.


RFC.


cargo install


cargo install . CLI-, Rust.


Rust 1.41.0, cargo install , . --force, .


Cargo.lock


, Cargo Cargo.lock, . , .


Rust 1.41.0 , . lock-, . , , PR, .


Box<T> FFI


Rust 1.41.0, , Box<T>, T: Sized, ABI C (T*). , extern "C" Rust C, Rust Box<T> - T, T* C. , C :


// C header */

//     
struct Foo* foo_new(void);

//     ; no-op   NULL.
void foo_delete(struct Foo*);

… Rust :


#[repr(C)]
pub struct Foo;

#[no_mangle]
pub extern "C" fn foo_new() -> Box<Foo> {
    Box::new(Foo)
}

//   NULL    `Option<_>`.
#[no_mangle]
pub extern "C" fn foo_delete(_: Option<Box<Foo>>) {}

, , Box<T> T* ABI, Box<T> -null, . , — Box', .


: Box<T> , C, Rust. C. Box<T>, C T* .


, Box<T>.



Rust 1.41.0, :



32- Apple


Rust 1.41.0 32- Apple, i686-apple-darwin. Rust 1.42.0 .


.



, Cargo Clippy . MIR, : "Inside Rust".


1.41.0


, Rust 1.41.0. , !



Rust - .


andreevlex, blandger, funkill, P0lunin nlinker.

Source: https://habr.com/ru/post/undefined/


All Articles