gtag('config', 'G-0PFHD683JR');
Price Prediction

Insert RUST 1.86.0: bottom features, hashmaps, and more

The RUST team is happy to announce a new version of RUST, 1.86.0. RUST is a programming language that enables everyone to build reliable and effective programs.

If you have a previous version of RUST installed via rustupYou can get 1.86.0 with:

$ rustup update stable

If you don’t have that already, you can get it rustup From the right page on our website, and verify the detailed version notes for 1.86.0.

If you want to help us by testing future versions, you may consider updating locally to use the beta channel (rustup default beta) Or the night channel (rustup default nightly). Please report any mistakes you may encounter!

What is in 1.86.0 stable

Rising features

This version includes a long -awaited feature – the ability to have features. If a feature contains a super cut, you can force a reference to the aforementioned object object into a sign of a feature of Supertrait:

trait Trait: Supertrait {}
trait Supertrait {}

fn upcast(x: &dyn Trait) -> &dyn Supertrait {
    x
}

The same will work with any other type of (smart) indicator, such as Arc -> Arc or *const dyn Trait -> *const dyn Supertrait.

Previously this required a solution in the form upcast The method of Trait It itself, for example fn as_supertrait(&self) -> &dyn SupertraitThis will only work for one type of reference/index. Such solutions are not necessary anymore.

Note that this means that the initial indicators of the characteristics of the features carry a trivial swamp: “leakage” of a raw indicator to a characteristic of VTABLE in an invalid in a safe symbol that may lead to an unspecified behavior. It has not been determined whether the creation of such a raw indicator is temporary in the well -controlled conditions causing immediate unlimited behavior, so the code should refrain from creating such indicators in any circumstances (and imposing Miri).

Useful features may be especially useful with Any A trait, because it allows your object to escalate to dyn Any To call AnySuccessful methods, without adding any ways to feature or use external boxes.

use std::any::Any;

trait MyAny: Any {}

impl dyn MyAny {
    fn downcast_ref(&self) -> Option<&T> {
        (self as &dyn Any).downcast_ref()
    }
}

You can learn more about the escalating features of the rust reference.

HashMapS and the slides now support the indexing of multiple elements in a clear way

The borrowing auditor prohibits the simultaneous use of the references obtained from repeated calls to get_mut Blind. To support this pattern safely, the standard library now provides a file get_disjoint_mut Assistant on slices and HashMap To recover the changeable signals to multiple elements simultaneously. See the following example taken from API documents for slice::get_disjoint_mut:

let v = &mut [1, 2, 3];
if let Ok([a, b]) = v.get_disjoint_mut([0, 2]) {
    *a = 413;
    *b = 612;
}
assert_eq!(v, &[413, 2, 612]);

if let Ok([a, b]) = v.get_disjoint_mut([0..1, 1..3]) {
    a[0] = 8;
    b[0] = 88;
    b[1] = 888;
}
assert_eq!(v, &[8, 88, 888]);

if let Ok([a, b]) = v.get_disjoint_mut([1..=2, 0..=0]) {
    a[0] = 11;
    a[1] = 111;
    b[0] = 1;
}
assert_eq!(v, &[1, 11, 111]);

Allow safe functions to distinguish them with #[target_feature] Describing.

Only previously unsafe Jobs can be distinguished #[target_feature] The characteristic is that it is not proper to call these jobs without enabling the goal advantage. This version settles target_feature_11 Feature, allow security Jobs to be distinguished with #[target_feature] Describing.

The safe and safe functions of feature features can only be called the goal only from other distinguished functions with the feature of the goal feature. However, it cannot be passed to the functions that accept the drugs that limit it Fn* The features and support are only forced into the job indicators within the jobs that carry a mark with target_feature Describing.

Inside the jobs are not distinguished by the feature of the goal, it can be called inside unsafe However, the caller is responsible for making sure the target feature is available.

#[target_feature(enable = "avx2")]
fn requires_avx2() {
    // ... snip
}

#[target_feature(enable = "avx2")]
fn safe_callsite() {
    // Calling `requires_avx2` here is safe as `safe_callsite`
    // requires the `avx2` feature itself.
    requires_avx2();
}

fn unsafe_callsite() {
    // Calling `requires_avx2` here is unsafe, as we must
    // ensure that the `avx2` feature is available first.
    if is_x86_feature_detected!("avx2") {
        unsafe { requires_avx2() };
    }
}

You can check out target_features_11 RFC for more information.

Correction assurances that indicators are not empty when needed to obtain safety

The software conversion program will now include correction assurances that the index is not wrong to the non -yellow readings and writing, and also when the index is re -storming into a reference. For example, the next code will now produce a state of unrelated panic when the correction assurances are enabled:

let _x = *std::ptr::null::();
let _x = &*std::ptr::null::();

Various examples such as this have produced a warning since RUST 1.53.0, the new operating time examination will discover these scenarios regardless of the complexity.

These assurances occur only when you enable the correction assurances, which means that they are It should not It depends on safety. This also means that the consequences that were assembled with disruption of correction assurances (for example the standard library) will not lead to assurances even when summoned by the code while enabling error correction.

Make missing_abi Al -Wad is a virtual warning

Delete ABI in external blocks and functions (for example extern {} and extern fn) It will now lead to a warning (across missing_abi Laur). Delete Abi yet extern The keyword has always implicitly resulted "C" my dad. It is now recommended to determine explicitly "C" Dad (for example extern "C" {} and extern "C" fn).

You can check for Extern Extern ABIS RFC for more information.

Warning of the targeted negligence of 1.87.0

Level 2 goal i586-pc-windows-msvc It will be removed in the next version of RUST, 1.87.0. A more popular band i686-pc-windows-msvc It is that it does not require the support of SSE2 instructions, but Windows 10, the minimum version of the operating system windows Goals (except win7 Goals), SSE2 instructions require themselves.

All users currently target i586-pc-windows-msvc You must migrate to i686-pc-windows-msvc before 1.87.0 It is released.

You can check the main change proposal for more information.

Stable application programming facades

  • {float}::next_down
  • {float}::next_up
  • <[_]>::get_disjoint_mut
  • <[_]>::get_disjoint_unchecked_mut
  • slice::GetDisjointMutError
  • HashMap::get_disjoint_mut
  • HashMap::get_disjoint_unchecked_mut
  • NonZero::count_ones
  • Vec::pop_if
  • sync::Once::wait
  • sync::Once::wait_force
  • sync::OnceLock::wait

These application programming facades are now stable in Const:

  • hint::black_box
  • io::Cursor::get_mut
  • io::Cursor::set_position
  • str::is_char_boundary
  • str::split_at
  • str::split_at_checked
  • str::split_at_mut
  • str::split_at_mut_checked

Other changes

Check out everything that has changed in rust, goods, and ClipPy.

Contributions in 1.86.0

Many people met to create 1 1.86.0. We could not do this without all of you. Thanks!


Credits

As published here

Photo by Nick Scholaen 💛💙 Unsplash

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button