basic/ownership/borrowing #645
Replies: 154 comments 141 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.
-
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.
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