basic/compound-type/string-slice #676
Replies: 71 comments 95 replies
-
可以补充一下字符串转义方面的内容吗? |
Beta Was this translation helpful? Give feedback.
-
fn main() { fn first_word(s: &String) -> &str { 关于这一段不是很理解,按照上一讲的说法,&s只在 //2 出现,之后就没有再使用了,范围应该是只在//2,&mut s的范围在 //3,这里报错是因为rust知道word是s的不可变引用,所以&s的范围是从 //2到 //4吗?rust是怎么知道的 |
Beta Was this translation helpful? Give feedback.
-
”+ 和 += 都是返回一个新的字符串。所以变量声明可以不需要 mut 关键字修饰。“,但是代码里就是用了mut,而且result还变了?这写错了? |
Beta Was this translation helpful? Give feedback.
-
少了一个“节“: |
Beta Was this translation helpful? Give feedback.
-
"数组切片和字符串切片的工作方式是一样的",有一些具体的细节还是没讲清楚: |
Beta Was this translation helpful? Give feedback.
-
关于字符串连接的第一个代码示例中的注释——” &string_rust会自动解引用为&str“。 |
Beta Was this translation helpful? Give feedback.
-
remove()函数返回的不是字符串,是字符类型。 |
Beta Was this translation helpful? Give feedback.
-
为什么String可变,声明的时候还要加mut呢 |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
为啥内部同时要弄utf8和unicode两种编码。。 |
Beta Was this translation helpful? Give feedback.
-
这里s1的所有权是被转移到了add方法的self? 理解起来有点怪。 |
Beta Was this translation helpful? Give feedback.
-
我又一个不成熟的问题、 |
Beta Was this translation helpful? Give feedback.
-
既然不支持索引,为什么要支持切片呢(切片的错误发生在run time,索引直接就在compile time了,也放到run time不好么,或者统一放到compile time) |
Beta Was this translation helpful? Give feedback.
-
有个问题想请教一下, 如果定义一个字符串引用, 例如 |
Beta Was this translation helpful? Give feedback.
-
既然String是可变的,那对String的不可变引用&str是不是把原来存在堆上的数据重新copy了一份到栈上? |
Beta Was this translation helpful? Give feedback.
-
最后一个String的联系链接404了 |
Beta Was this translation helpful? Give feedback.
-
很奇怪啊,rust中pop的实现:```rust
|
Beta Was this translation helpful? Give feedback.
-
最后一个练习的链接似乎需要从大写S改成小写s。 |
Beta Was this translation helpful? Give feedback.
-
切片后的字符串是什么类型呢? 内存是怎么管理的, 是跟原字符串共用的一片内存吗? 因为我原先是学习C的, C里面\0表示字符串结束, 那么在这里如果共用的话, rust是字符串是有自己的逻辑来判断字符串的终止? |
Beta Was this translation helpful? Give feedback.
-
String的课后作业页面Page Not Found 了 |
Beta Was this translation helpful? Give feedback.
-
rust的字符串比js、java复杂太多了。 |
Beta Was this translation helpful? Give feedback.
-
insert的第一个参数是字节位置,如果字符串中是中文,会崩溃!!! insert说明 |
Beta Was this translation helpful? Give feedback.
-
fn string_add() -> () {
let test_add = String::from("qqq123");
let str_rht = String::from("rust");
let test_add = test_add + str_rht.as_str();
println!("test_add: {}", test_add);
} 请容许我借这段代码向您讲解一下,rust的mut机制。 fn string_add() -> () {
let test_add = String::from("qqq123");
let str_rht = String::from("rust");
let test_add = test_add + str_rht.as_str();
str_rht.push_str("dsad");
println!("test_add: {}", test_add);
} 我们新增了一个str_rht.push_str, 请你判断这个函数是否能够被成功编译? 那么根据我上面所讲述的,请你改写这一句使可以通过编译吧。 |
Beta Was this translation helpful? Give feedback.
-
刚学到这里,字符串删除方法中说 |
Beta Was this translation helpful? Give feedback.
-
"A b A b A b A b A" -> "A b A b B b B b A" rust 大牛们能给个 replace 函数不支持索引的理由吗?这种场景真就不 care 吗? |
Beta Was this translation helpful? Give feedback.
-
初学rust,在char, str, &str, String, &String中迷惑。
|
Beta Was this translation helpful? Give feedback.
-
truncate方法的解释有误,应该是从开始截取指定长度的字符串 |
Beta Was this translation helpful? Give feedback.
-
我开始赞同 Rust 为什么反内卷了,光是一个字符串的增删改已经把大部分人劝退了。希望我能坚持下来,不要被别人卷走。 |
Beta Was this translation helpful? Give feedback.
-
内容很扎实,学到了! |
Beta Was this translation helpful? Give feedback.
-
既然做了切片是否落在字符边界的运行时检查,为什么不干脆切片以Unicode码点为单位呢……这样也顺便支持了下标访问 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
basic/compound-type/string-slice
https://course.rs/basic/compound-type/string-slice.html
Beta Was this translation helpful? Give feedback.
All reactions