Puo ea Rust programming 1.58 tokollo

Ho lokolloa ha puo ea mananeo a akaretsang Rust 1.58, e thehiloeng ke morero oa Mozilla, empa hona joale e ntlafalitsoeng ka tlas'a ts'ebetso ea mokhatlo o ikemetseng o sa etseng phaello ea Rust Foundation, e hatisitsoe. Puo e tsepamisitse maikutlo holim'a ts'ireletso ea mohopolo, e fana ka taolo ea memori ea othomathike, 'me e fana ka mekhoa ea ho fihlela ts'ebetso e phahameng ea ts'ebetso ntle le ho sebelisa pokello ea lithōle kapa nako ea ho sebetsa (nako ea ho sebetsa e fokotsehile ho qala le ho boloka laebrari e tloaelehileng).

Taolo ea memori ea othomathike ea Rust e felisa liphoso ha e tsamaisa lintlha le ho sireletsa khahlanong le mathata a bakoang ke ho qhekella ha memori ea boemo bo tlase, joalo ka ho fihlella sebaka sa memori kamora hore e lokolloe, li-null pointer dereferences, buffer overruns, jj. Ho aba lilaebrari, ho etsa bonnete ba ho kopanya le ho laola ba itšetlehileng ka bona, morero o nts'etsapele mookameli oa thepa ea thepa. Sebaka sa polokelo ea crates.io se tšehetsoa bakeng sa lilaebrari tse amohelang batho.

Litlhahiso tse ka sehloohong:

  • Ka li-block formatting, ho phaella ho bokhoni bo neng bo le teng pele ba ho fetola mefuta-futa e thathamisitsoeng ka ho hlaka ka mor'a khoele ka nomoro le lebitso, bokhoni ba ho kenya li-identifiers tse hanyetsanang ka ho kenyelletsa poleloana "{identifier}" ho khoele e kenngoa ts'ebetsong. Mohlala: // Mehaho e neng e ts'ehelitsoe pele: println!("Hello, {}!", get_person()); println!("Dumela, {0}!", get_person()); println!("Dumela, {motho}!", motho = get_person()); // joale o ka hlakisa tlohella motho = get_person(); println!("Lumela, {motho}!");

    Li-Identifiers le tsona li ka hlalosoa ka kotloloho likhethong tsa ho fometa. let (bophara, ho nepahala) = get_format(); bakeng sa (lebitso, lintlha) ho get_scores() {println!("{name}: {score:width$.precision$}"); }

    Phatlalatso e ncha e sebetsa ho li-macros tsohle tse tšehetsang tlhaloso ea sebopeho sa likhoele, ntle le "panic!" macro. liphetolelong tsa 2015 le 2018 tsa puo ea Rust, moo ho tšoha!("{ident}") e tšoaroa e le khoele e tloaelehileng (ho Rust 2021 phetoho e sebetsa).

  • Boitšoaro ba std::process::Sebopeho sa taelo sethaleng sa Windows se fetotsoe hore ha ho etsoa litaelo, ka mabaka a ts'ireletso, e se ke ea hlola e sheba lifaele tse ka phethoang bukeng ea hona joale. Sengoloa sa hajoale ha se kenyellelitsoe hobane se ka sebelisoa ho sebelisa khoutu e mpe haeba mananeo a tsamaisoa ka li-directory tse sa tšepahaleng (CVE-2021-3013). Mokhoa o mocha oa ho sibolla o kenyelletsa ho batla li-directory tsa Rust, bukana ea kopo, bukana ea sistimi ea Windows, le li-directory tse boletsoeng ho phapano ea tikoloho ea PATH.
  • Laeborari e tloaelehileng e ekelitse palo ea mesebetsi e tšoailoeng "#[most_use]" ho fana ka temoso haeba boleng ba ho khutla bo hlokomolohuoa, e thusang ho tseba liphoso tse bakiloeng ke ho nka hore ts'ebetso e tla fetola boleng ho fapana le ho khutlisa boleng bo bocha.
  • Karolo e ncha ea API e fetiselitsoe sehlopheng sa ba tsitsitseng, ho kenyelletsa le mekhoa le ts'ebetsong ea mekhoa e tsitsitseng:
    • Metadata::is_symlink
    • Tsela::is_symlink
    • {integer}::saturating_div
    • Kgetho:: unwrap_e sa hlahlojwa
    • Sephetho::unwrap_unchecked
    • Sephetho::unwrap_err_unchecked
  • Sebopeho sa "consst", se khethollang monyetla oa ho se sebelisa maemong afe kapa afe ho fapana le li-constants, se sebelisoa mesebetsing:
    • Nako::e ncha
    • Nako::checked_eketsa
    • Nako::e khotsofatsang_eketsa
    • Nako::checked_sub
    • Nako::saturating_sub
    • Nako::checked_mul
    • Nako::saturating_mul
    • Nako::checked_div
  • E lumelletsoe ho khelosoa ha litsupa tsa "*const T" maemong a "const".
  • Ho mookameli oa sephutheloana sa Cargo, tšimo ea rust_version e kentsoe metadata ea sephutheloana, 'me khetho ea "--message-format" e kentsoe taelong ea "cargo install".
  • Moqapi o sebelisa ts'ehetso bakeng sa mochini oa ts'ireletso oa CFI (Control Flow Integrity), o eketsang licheke pele ho mohala o mong le o mong o sa tobang ho bona mefuta e meng ea boitšoaro bo sa hlalosoang bo ka lebisang tlolong ea taelo e tloaelehileng ea ts'ebetso (phallo ea taolo) ka lebaka la tshebediso ya mesebetsi e fetolang mesupo e bolokilweng mohopolong wa ditshebetso.
  • Moqapi o kentse tšehetso bakeng sa liphetolelo tsa 5 le 6 tsa sebopeho sa papiso ea LLVM, e sebelisetsoang ho hlahloba tšireletso ea khoutu nakong ea tlhahlobo.
  • Sebokeng, litlhoko tsa mofuta o tlase oa LLVM li phahamisetsoa ho LLVM 12.
  • Boemo ba boraro ba tšehetso bakeng sa sethala sa x86_64-se sa tsejoeng-ha se se se kentsoe ts'ebetsong. Boemo ba boraro bo kenyelletsa ts'ehetso ea mantlha, empa ntle le tlhahlobo ea boiketsetso, meaho ea semmuso ea phatlalatso, kapa ho hlahloba hore na khoutu e ka hahuoa.

Ho feta moo, re ka ela hloko phatlalatso ea Microsoft ea ho lokolloa ha Rust bakeng sa lilaebrari tsa Windows 0.30, tse u lumellang hore u sebelise puo ea Rust ho theha lits'ebetso tsa Windows OS. Setha se kenyelletsa liphutheloana tse peli tsa crate (lifensetere le lifensetere-sys), tseo ka tsona u ka fihlelang Win API ho mananeo a Rust. Khoutu bakeng sa tšehetso ea API e hlahisoa ka matla ho tsoa ho metadata e hlalosang API, e u lumellang ho kenya ts'ehetso eseng feela bakeng sa mehala ea Win API e teng, empa bakeng sa mehala e tla hlaha nakong e tlang. Phetolelo e ncha e eketsa tšehetso bakeng sa sethala sa sepheo sa UWP (Universal Windows Platform) mme e sebelisa mefuta ea Handle le Debug.

Source: opennet.ru

Eketsa ka tlhaloso