basic/ownership/borrowing #645
Replies: 157 comments 148 replies
-
|
讲的很好 |
Beta Was this translation helpful? Give feedback.
-
|
同一时刻,你只能拥有要么一个可变引用, 要么任意多个不可变引用。这个同一时刻怎么理解?还是同一作用域? |
Beta Was this translation helpful? Give feedback.
-
|
可变引用与不可变引用不能同时存在小节下的
这一段是否应该改为
|
Beta Was this translation helpful? Give feedback.
-
|
引用、借用,这章感觉有点绕。引用是语法层面的,借用是概念层面的,可以这么理解么 |
Beta Was this translation helpful? Give feedback.
-
|
无法在函数结束后返回引用,正如无法在法国投降前攻下巴黎 |
Beta Was this translation helpful? Give feedback.
-
|
好! |
Beta Was this translation helpful? Give feedback.
-
|
感觉跟指针差不多, 但是没有 |
Beta Was this translation helpful? Give feedback.
-
|
很润 😂 |
Beta Was this translation helpful? Give feedback.
-
|
看来之前学习Rust走错路了,之前直接看英文教程,本母语为中文的开发者,理解是真不到位,现在重新学一遍,瞬间豁然开朗了 |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
感谢,确实比官方的文档更细致入微,之前看了几遍官方文档也没真正弄懂,现在终于搞懂了! |
Beta Was this translation helpful? Give feedback.
-
|
同一作用域,特定数据只能有一个可变引用 |
Beta Was this translation helpful? Give feedback.
-
fn main() {
let mut s = String::from("456");
let mut n = &mut s;
foo(&mut n);
}
fn foo(s: &mut String) {
let m = s;
m.push_str("asd")
}fn main() {
let mut s = String::from("456");
let n = &mut s;
foo(n);
}
fn foo(s: &mut String) {
let m = s;
m.push_str("asd")
}这三个都可以运行🤨 |
Beta Was this translation helpful? Give feedback.
-
|
开始最难的阶段 |
Beta Was this translation helpful? Give feedback.
-
|
借用在值的改变上,既然String可以使用&mut进行改变,为什么同样使用基本类型却没办法进行改变了,有点一丢丢感觉不合理,这不是欺负老实人嘛! |
Beta Was this translation helpful? Give feedback.
-
|
讲解的很好,下次继续讲解 |
Beta Was this translation helpful? Give feedback.
-
|
刚开始学习不知道底层的实现逻辑,但是我觉得可变引用和不可变引用跟读写锁的逻辑很相似 |
Beta Was this translation helpful? Give feedback.
-
|
求解惑,一开始关于解引用的例子,我用rustc 1.84.1 (e71f9a9a9 2025-01-27)版本的编译器时,对于这部分代码: |
Beta Was this translation helpful? Give feedback.
-
|
写得太好了,受不了了 |
Beta Was this translation helpful? Give feedback.
-
|
有难度, 没有完全听懂~ 后来再来看看~ |
Beta Was this translation helpful? Give feedback.
-
|
借用和可变借用,有点儿读写锁的意思 |
Beta Was this translation helpful? Give feedback.
-
|
对借用的借用是谁的借用? } |
Beta Was this translation helpful? Give feedback.
-
|
第二次看引用与借用,发现更多细节! |
Beta Was this translation helpful? Give feedback.
-
|
讲的确实不错 |
Beta Was this translation helpful? Give feedback.
-
|
讲的很不错! |
Beta Was this translation helpful? Give feedback.
-
|
有点像互斥锁和共享锁🌚 |
Beta Was this translation helpful? Give feedback.
-
|
翻译为 ‘借用与租用’ 是不是更符合使用场景 |
Beta Was this translation helpful? Give feedback.
-
|
当有了一个可变引用后,原始变量和这个引用是不是都能修改数据?不还是有数据竞争吗? |
Beta Was this translation helpful? Give feedback.
-
|
fn calculate_length(s: &String) -> usize { // s 是对 String 的引用 为什么在这里例子里,s.len() 没有使用解引用符号?为什么没有写成 (*s).len() ? |
Beta Was this translation helpful? Give feedback.
-
|
最后一个转移所有权真是绝妙! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
basic/ownership/borrowing
https://course.rs/basic/ownership/borrowing.html
Beta Was this translation helpful? Give feedback.
All reactions