我在这里找到一个参考:https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/r...
Rust Reference 的中文翻译,预期能及时和原文保持同步 展开 收起 暂无标签 Rust 等4 种语言 Apache-2.0 保存更改 取消 发行版 (2) 全部 抢救版 4年前 rust-reference 开源评估指数 生产力 创新力 稳健性 协作 贡献者 软件 贡献者 (5) 全部 近期动态 4个月前推送了新的提交到 master ...
借用规则 引用(reference)不获取所有权,坚持单一所有者和单一职责,解决了共享访问障碍。按引用传递对象的方式称作借用 (borrow), 这比转移所有权更有效 一个引用的生命周期,一定不会超过其被引用的时间。这显而易见的,为了防止悬垂引用 如果存在一个值的可变借用,那么在该借用作用域内,不允许有其它引用(读或写) ...
定义:The &s1 syntax lets us create a reference that refers to the value of s1 but does not own it 翻译:s1 是一个「值」;而 &s1 就是指向这个「值」的「引用」(但并不 own 这个「值」) Rust 提供了「引用」这种方式来 access 一个 value:可使用 value,但不 own 这个 value。又分为 2 种「...
To build the Reference, first clone the project: git clone https://github.com/rust-lang/reference.git (Alternatively, if you don't want to usegit,downloada ZIP file of the project, extract it using your preferred tool, and rename the top-level directory toreference.) ...
// ^ `s` is a `&` reference, // so the data it refers to cannot be borrowed as mutable //s.push_str("okok"); //如果要修改,传入的引用必须是可变引用 //增加mut关键字,使用引用内存可修改 s.push_str("===>HelloWorld!");
rust reference 中文翻译. Contribute to KaiserY/rust-reference-chinese development by creating an account on GitHub.
letmutv=vec![1973,1968];// implicitly borrows a mutable reference to// 因为sort的函数签名是&mut self,从而v.sort() 使用时将会隐式地进行&mut vv.sort();// 与v.sort()效果一样(&mutv).sort();// explicitly borrows a mutable referenceletv_ref=&mutv;v_ref.sort(); ...
fnmain() {letreference_to_nothing=dangle(); }fndangle()->&String{// dangle returns a reference to a Stringlets=String::from("hello");// s is a new String&s// we return a reference to the String, s}// Here, s goes out of scope, and is dropped. Its memory goes away.// Dan...
前面提到 Rust 为了实现内存无运行时的自动管理,引入了独创的生命周期 (lifetime)和 所有权 (ownership), 对于学习 Rust 的同学来说,这是必须跨过去的坎,接着还有类似引 用 (Reference),租借 (Borrow) 这些特性,真的令人望而生畏。 而 Rust 的很多新的特性 都是没办法从已有的编程语言那里找到类似的特性的,...