一长串代码好啰嗦啊 阅读也不好阅读 Rust 每日一题
下面哪个选项可以将一个String类型的值转换为一个&str类型的值?
A. let s: String = "hello".to_string(); let t: &str = s.into();
B. let s: String = "hello".to_string(); let t: &str = s as &str;
C. let s: String = "hello".to_string(); let t: &str = &s;
D. let s: String = "hello".to_string(); let t: &str = str::from(s);
下面哪个选项可以将一个String类型的值转换为一个&str类型的值?
A. let s: String = "hello".to_string(); let t: &str = s.into();
B. let s: String = "hello".to_string(); let t: &str = s as &str;
C. let s: String = "hello".to_string(); let t: &str = &s;
D. let s: String = "hello".to_string(); let t: &str = str::from(s);
展开
1
1