U ka kenya puo ea Rust ho Linux joang?

mafome

C le C ++ ha ho pelaelo hore e bile e 'ngoe ea lipuo tse tsebahalang haholo tsa mananeo mme e sebelisoa ke bongata ba likopo le lits'ebetso tsa ts'ebetso le ntle le ho re ke e 'ngoe ea lipuo tsa pele tse khothalelitsoeng tsa ho ithuta 'me u nke e le motheo.

Mafome ke puo ea lenaneo hlophisitsoeng, morero oa kakaretso le ngatafatso ke hore e ntlafalitsoe ke Mozilla mme e tšehelitsoe ke LLVM. Puo ena e etselitsoe ho ba «Puo e bolokehileng, e lumellanang le e sebetsang» mme ka holim'a tsohle ho ba Phetolo ea lipuo tsa C le C ++.

mafome ke puo e bulehileng ea lenaneo la mohloli e tšehetsang lenaneo le hloekileng la ts'ebetso, Tsamaiso, taolo le sepheo sa dintho.

Puo ena ea lenaneo e sebetsa ka potlako, e qoba likarolo, mme e netefatsa polokeho ea likhoele. E ts'ehetsa litšenyehelo tse sa lefelloeng, li-semantics tsa motsamao, ts'ireletso ea memori e netefalitsoeng, merabe e se nang likhoele, semelo se thehiloeng ho generic le papiso e tšoanang.

Hape e ts'ehetsa mofuta oa mofuta, nako e nyane ea ho etsa, hammoho le litlamo tse sebetsang tsa C.

mafome e ka tsamaisoa ka palo e kholo ea sethala 'me e ntse e sebelisoa ho hlahisa lik'hamphani / mekhatlo e kang Dropbox, CoreOS, NGP le tse ling tse ngata.

Morero oa Rust ke ho ba puo e ntle bakeng sa ho theha mananeo a matle a bareki le li-server a sebetsang marang-rang.

Sena se lebisitse ho sete ea likarolo ka ho hatisa polokeho, taolo ea kabo ea mohopolo le concurrency.

Ts'ebetso ea khoutu e bolokehileng e lebelletsoe ho lieha ho feta C ++, haeba ts'ebetso e le eona feela e nahanoang, empa ha e bapisoa le khoutu ea C ++ e etselitsoeng ho nka mehato ea ho itšireletsa e ts'oanang le Rust, ea morao e ka ba lebelo le ho feta.

Rust syntax e ts'oana le C le C ++, e nang le li-block-delimised code block le li-flow control structures joalo ka ha ho le joalo, etsa joalo, le ha.

Mafome 1

Ha se likarolo tsohle tsa C le C ++ tse teng, 'me tse ling (joalo ka lebitso la sehlooho la papali bakeng sa makala a mangata a fapaneng) li ke ke tsa tsebahala haholo ho baetsi ba mananeo ba tsoang lipuong tsena.

Ho kenya mafome ho Linux

Si u batla ho kenya puo ena ea lenaneo tsamaisong ea hau, Re ka e etsa ka ho jarolla se kentsoeng se tla re thusa ho fumana mafome tsamaisong ea rona

Bula terminal ebe u matha ho eona:

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

Ha o tsamaisa taelo ena se kenyang se tla jarollwa mme se tla sebetsa hanghang, o hloka ho tobetsa 1 ho tsoela pele ka ho kenya ka litekanyetso tsa mantlha mme e tla jarolla lipakete tsohle tse hlokahalang.

Haeba o batla ho kenya moetlo, o tlameha ho thaepa 2 mme o tla hlalosa mefuta-futa ea tikoloho ea hau har'a lintho tse ling.

Qetellong ea ho kenya mafome tsamaisong ea rona, Lethathamo la libene tsa Cargo le tla eketsoa hanghang tseleng e latelang ( ~ / .cargo / bin) moo lisebelisoa tsohle li kentsoeng) moeling oa hau oa PATH, in ~ / .profile.

E entse sena re tlameha ho tsoela pele ho hlophisa Shell, re etsa sena ka ho fetola file ea ~ / .profile ho sebelisa PATH e fetotsoeng ho sebetsa le tikoloho ea Rust, ho tsamaisa litaelo tsena ho terminal:

source ~/.profile
source ~/.cargo/env

Hona joale feela Re tlameha ho tsoelapele ho netefatsa hore Rust e kentsoe ka nepo tsamaisong ea rona, re etsa sena ka ho thaepa taelo e latelang ho terminal

rustc --version

Le eona re lokela ho amohela mofuta oa Rust skrineng tseo re li kentseng tsamaisong ea rona.

Mme ke phetho, re ka qala ho sebelisa puo ena mme ra khona ho kenya lits'ebetso tse e sebelisang tsamaisong ea rona.

Ho leka puo re ka etsa faele e bonolo re printe molaetsa skrineng, re etsa sena ka ho thaepa tse latelang:

nano prueba.rs

Ka hare ho faele re maneha tse latelang:

fn main() {
println!("Prueba exitosa de Rust");
}

Re e fetola ntho e ka sebetsoang:

rustc prueba.rs

Mme re e matha ho ea leka:

./prueba.rs


Litaba tsa sengoloa sena li latela melao-motheo ea rona ea melao ea boitšoaro ea bongoli. Ho tlaleha phoso tlanya mona.

Tlhaloso, tlohela ea hau

Siea maikutlo a hau

aterese ya hao ya imeile ke ke ho phatlalatswa.

*

*

  1. E ikarabella bakeng sa data: Miguel Ángel Gatón
  2. Morero oa data: Laola SPAM, tsamaiso ea maikutlo.
  3. Molao: Tumello ea hau
  4. Puisano ea data: Lintlha li ke ke tsa tsebisoa batho ba boraro ntle le ka tlamo ea molao.
  5. Polokelo ea data: Database e hapiloeng ke Occentus Networks (EU)
  6. Litokelo: Nako efe kapa efe o ka fokotsa, oa hlaphoheloa mme oa hlakola tlhaiso-leseling ea hau.

  1.   kissy a re

    Mme ho ne ho ke ke ha ba bonolo ho joetsa batho hore ba e kenye ho e batla polokelong ea kabo ea eona ... Hobane joalo ka ha o re ... o tlosa joang? ...

    Ke sebelisa setaele sa Debian, 'me ho bonahala eka ha e hloke ho feta: sudo apt-get kenya rustc.

    Joalokaha u bona khokahanong ena, e lipolokelong tsa Debian ho tloha phetolelong ea ho qetela e tsitsitseng:
    https://packages.debian.org/search?keywords=rustc
    le ho Ubuntu ho tsoa Trusty (14.04LTS):
    https://packages.ubuntu.com/search?keywords=rustc&suite=default&section=all&arch=any&searchon=names

    Hlokomela seo u se khothalletsang, hore mosebelisi ofe kapa ofe oa li-novice a ka qhekella habonolo ntle le tlhoko!