Rust 1.66 Programming Language Tso tawm

Kev tso tawm ntawm Rust 1.66 cov lus qhia dav dav, tsim los ntawm Mozilla qhov project, tab sis tam sim no tsim los ntawm kev txhawb nqa ntawm lub koom haum ywj pheej tsis muaj txiaj ntsig Rust Foundation, tau tshaj tawm. Cov lus qhia txog kev nyab xeeb ntawm kev nco thiab muab txoj hauv kev kom ua tiav txoj haujlwm siab sib luag thaum tsis txhob siv cov khoom siv khib nyiab thiab lub sijhawm ua haujlwm (runtime raug txo qis rau kev pib pib thiab kev saib xyuas ntawm lub tsev qiv ntawv txheem).

Rust lub cim xeeb tuav txoj kev cawm tus tsim tawm los ntawm kev ua yuam kev thaum tswj cov taw qhia thiab tiv thaiv cov teeb meem uas tshwm sim los ntawm kev ua haujlwm qis qis, xws li nkag mus rau thaj chaw nco tom qab nws tau tso tawm, dereferencing null pointers, tsis overruns, thiab lwm yam. Txhawm rau faib cov tsev qiv ntawv, muab kev tsim kho thiab tswj hwm kev vam khom, qhov project tsim tus thawj tswj hwm pob khoom. Lub crates.io repository yog txaus siab rau hosting cov tsev qiv ntawv.

Kev nyab xeeb nco yog muab rau hauv Rust ntawm lub sijhawm sau los ntawm kev siv tshuaj xyuas, ua raws li cov tswv cuab ntawm cov khoom, khaws cov khoom siv lub neej (scopes), thiab ntsuas qhov tseeb ntawm kev nkag mus rau lub cim xeeb thaum lub sijhawm ua tiav cov lej. Rust kuj tseem muab kev tiv thaiv tus lej ntau dhau, yuav tsum muaj qhov sib txawv kom pib ua ntej siv, ua haujlwm yuam kev zoo dua hauv cov tsev qiv ntawv tus qauv, siv lub tswv yim ntawm cov ntaub ntawv tsis hloov pauv thiab hloov pauv los ntawm lub neej ntawd, thiab muaj kev ntaus ntawv zoo li qub kom txo qis qhov yuam kev.

Main innovations:

  • Hauv kev suav nrog cov lej suav suav (tus "#[repr(Int)]" tus cwj pwm), qhia meej txog qhov kev ntxub ntxaug (tus naj npawb ntawm cov kev xaiv hauv kev suav) raug tso cai, txawm tias qhov suav suav muaj cov teb. #[repr(u8)] enum Foo { A(u8), # discriminant 0 B(i8), # discriminant 1 C(bool) = 42, # discriminant 42 }
  • Ntxiv core::hint::black_box muaj nuj nqi, uas tsuas xa rov qab tus nqi tau txais. Vim hais tias lub compiler ntseeg hais tias ib tug muaj nuj nqi ua ib yam dab tsi, lub black_box muaj nuj nqi yuav siv tau los lov tes taw lub compiler optimization ntawm loops thaum ua code kev ua tau zoo xeem los yog thaum soj ntsuam cov generated tshuab code (kom lub compiler tsis xav txog cov code unusable thiab tshem tawm. nws). Piv txwv li, hauv qhov piv txwv hauv qab no, kev qhia black_box(v.as_ptr()) tiv thaiv lub compiler los ntawm kev xav tias vector v tsis siv. siv std::hint::black_box; fn push_cap(v: &mut Vec) { rau kuv hauv 0..4 { v.push(i); black_box(v.as_ptr()); }}
  • Tus neeg saib xyuas pob "cargo" muab cov lus txib "tshem tawm", uas tso cai rau koj tshem tawm cov kev vam meej ntawm Cargo.toml manifest los ntawm kab hais kom ua.
  • Ib feem tshiab ntawm API tau raug hloov mus rau qeb ntawm qhov ruaj khov, suav nrog cov txheej txheem thiab kev siv ntawm cov yam ntxwv tau ruaj khov:
    • proc_macro::Span::source_text
    • u*::{checked_add_signed, overflowing_add_signed, saturating_add_signed, wrapping_add_signed}
    • i*::{checked_add_unsigned, overflowing_add_unsigned, saturating_add_unsigned, wrapping_add_unsigned}
    • i*::{checked_sub_unsigned, overflowing_sub_unsigned, saturating_sub_unsigned, wrapping_sub_unsigned}
    • BTreeSet::{ua ntej, kawg, pop_first, pop_last}
    • BTreeMap::{first_key_value, last_key_value, first_entry, last_entry, pop_first, pop_last}
    • Ntxiv AsFd kev siv rau stdio lock hom thaum siv WASI.
    • impl TryFrom > rau Box<[T; N]>
    • core::hint::black_box
    • Duration::try_from_secs_{f32,f64}
    • Kev xaiv:: unzip
    • std:: os:: fd
  • Kev siv ntau yam β€œ..X” thiab β€œ..=X” raug tso cai hauv cov qauv.
  • Thaum sib sau ua ke lub frontend ntawm rustc compiler thiab backend ntawm LLVM, optimization hom LTO (Txuas Lub Sijhawm Optimization) thiab BOLT (Binary Optimization thiab Layout Tool) yog siv, uas tso cai rau kev ua tau zoo ntawm cov txiaj ntsig tau txais txiaj ntsig thiab txo qis kev nco.
  • Qhov thib peb theem ntawm kev txhawb nqa tau siv rau armv5te-none-eabi thiab thumbv5te-none-eabi platforms. Qib thib peb suav nrog kev txhawb nqa yooj yim, tab sis tsis muaj kev sim automated, tshaj tawm kev tsim kho, lossis tshawb xyuas seb qhov chaws puas tuaj yeem tsim.
  • Ntxiv kev txhawb nqa rau kev txuas nrog macOS universal tsev qiv ntawv.

Tsis tas li ntawd, peb tuaj yeem nco ntsoov qhov suav nrog hauv ntej kawg ntawm Rust language compiler (gccrs) hauv GCC code puag. Lub frontend suav nrog hauv GCC 13 ceg, uas yuav tshaj tawm thaum lub Tsib Hlis 2023. Pib nrog GCC 13, cov cuab yeej hauv GCC tuaj yeem siv los sau cov kev pab cuam hauv Rust hom lus yam tsis tas yuav nruab rustc compiler, tsim siv LLVM kev txhim kho. Kev siv GCC 13 ntawm Rust yuav yog beta version, tsis tau qhib los ntawm lub neej ntawd.

Tau qhov twg los: opennet.ru

Ntxiv ib saib