Iyo nyowani vhezheni yeRust 1.30.0 inosvika neyakavandudzwa module system uye nezvimwe

Ngura logo ine giya

Ngura kana ngura-lang iyo iri yemazuva ano uye yakavhurwa sosi programming mutauro, mukuwedzera pakuve multiplatform, nekukurumidza uye yakagadzirirwa kutsiva C uye C ++.

Yakagadzirwa neMozilla uye ine yepamusoro-soro kubvisirwa kufadza zvakare avo vanobva kuC # neJava.

Uye hazvisi izvo chete, isu tinogona kuona zvakawanda zvinonakidza maficha zvisingaoneke mune mimwe mitauro yekuronga, senge zero mutengo unokanganisa, mafambiro ekufamba, chengetedzo yekurangarira, yakaderedzwa nguva yekuuraya, nezvimwe.

Nezve iyo nyowani vhezheni yeRust 1.30.0

Vagadziri veRust vakazivisa vhezheni itsva 1.30.0 yemutauro wako wechirongwa.

Iyi vhezheni itsva yemutauro, inowedzera mhando nyowani yemaitiro macros, inotsanangura kushanda kwayo se "shandisa", uye inovandudza iyo module system.

Hunhu uye mashandiro-senge maitiro macros ndiwo matsva ekuwedzera kuRust 1.30.0.

Iwo ekutanga akafanana netsika Derive macros, asi bvumidza iwe kutsanangura nyowani uye tsika hunhu kuwedzera panzvimbo pehunhu "# [Tsvaga]", Kukutendera iwe kuti ugadzire yako itsva tsika hunhu.

Zvakare, ivo havangoshandire chete zvivakwa uye enum, asiwo zvemabasa.

Dzimwe shanduko uye hutsva zvinotsanangura chiziviso chepamutemo chechazvino vhezheni, pamwe neayo mashoma mashoma akasunungurwa manotsi paGithub.

About "rustup kugadzirisa yakagadzika" inogona kunge iri nyowani Rust vhezheni.

Rust 1.30 inowedzera pane izvi nekuwedzera kugona kutsanangura mamwe maviri epamberi macro mhando, "Attribute-like procedural macros" uye "Function-like procedural macros".

Ivo zvakare vanochinjika - kuwana chete mabasa ezvivakwa uye enum, asi hunhu hunogona kuenda kumwe kunhu, semabasa.

Semuenzaniso wekushandisa hunhu-senge macro, unogona kuve nechimwe chinhu chakadai kana uchishandisa webhu sisitimu yekushandisa.

Basa-senge maitiro macros anotsanangura macros anotaridzika kunge mafoni ekufona. Kana iri SQL, ichi chingave chinhu chakadai.

let sql = sql! (SELECT * FROM posts WHERE id = 1); 

Iyo macro, inozivikanwa nekushamisika poindi, yaizoenzanisira yakadzamidzirwa SQL chirevo uye yekutarisa syntactic kururamisa, sekureva kweshanduro nyowani. Inogona kutsanangurwa kuburikidza:

# [Proc_macro]

pub fn sql (input: TokenStream) -> TokenStream {...} 

Pano, iyo inoshanda-senge macro inotevera iyo Derive macro nekuongorora iyo kodhi mumabhureki uye kudzorera iyo kodhi inogadzirwa.

Panguva imwecheteyo, iyo yepamusoro notation "# [Macro_use]" yaishandiswa kushandisa ekunze bhokisi macros. Inotsiva kushandiswa kwe "shandisa."

Yakagadziriswa module system.

Kwete zvishoma zvakakosha, ivo vanogadzira vavandudza module module kana kushandura mimwe yakaoma uye isina kujairika syntax mitemo.

Kusvika parizvino, matambudziko amuka apo vanogadzira vanofambisa basa kuenda muchidimbu pasina yakajeka "shandisa" chivakamberi

Ngura 1.30.0

Ngura ichangotarisa nzira kuti ione otomatiki kana iri bhokisi rekunze. Kana zvirizvo, inozoshandiswa zvisinei nenzvimbo iripo muchikamu chemojuru.

Ngura inoenderanawo nekushandisa kweshoko rekuti «crate». Semuenzaniso, "shandisa crate :: foo :: bar;" inoratidza kuti nzira inoenda ku "bar" basa inotanga kubva ku foo module mune dhairekitori rebhokisi, kwete kubva kudhairekitori razvino.

Izvi zvinobvumidza, semuenzaniso, kudaidza mashandiro emo module nhamba 1 kunze kwekushanda kwemo module nhamba 2 pasina kushandisa "use".

Maitiro ekuisa Rust 1.30.0 paLinux?

Kune avo vanofarira kuisa Rust pane yavo masystem, ivo vanofanirwa kurodha pasi inodiwa package mune yedu distro, kune izvi isu tichazoshandisa curl:

curl https://sh.rustup.rs -sSf | sh 

Nezvo isu tinowana saiti uye kumhanya iyo script.

Nhevedzano yesarudzo ichavhura kwatiri mune yedu terminal uye isu tinofanirwa kupindura nenzira kwayo. Iwe unofanirwa kudzvanya 1 kuti uenderere mberi nekumisikidza nemitengo yakasarudzika, iyo inokurudzirwa kune vakawanda.

Kana tangopedza tinogona kumisikidza yedu yazvino Shell kuti itange kushanda:

source $HOME/.cargo/env 

Uye isu tinogona kutanga kuishandisa. Semuenzaniso, kana iwe uchida kuona iyo vhezheni yawakangoisa uye woongorora kuti zvese zvakanaka:

rustc --version 

Kana iwe uine Rust yakaiswa uye iwe uchida kugadzirisa kune iyo nyowani vhezheni, iwe unofanirwa kungo nyora:

rustup update stable 

Izvo zviri muchinyorwa zvinoomerera pamisimboti yedu ye tsika dzekunyora. Kuti utaure chikanganiso tinya pano.

Iva wekutanga kutaura

Siya yako yekutaura

Your kero e havazobvumirwi ichibudiswa.

*

*

  1. Inotarisira data: AB Internet Networks 2008 SL
  2. Chinangwa cheiyo data: Kudzora SPAM, manejimendi manejimendi.
  3. Legitimation: Kubvuma kwako
  4. Kutaurirana kwedata
  5. Dhata yekuchengetedza: Dhatabhesi inobatwa neOccentus Networks (EU)
  6. Kodzero: Panguva ipi neipi iwe unogona kudzora, kupora uye kudzima ruzivo rwako