mirror of
https://github.com/gnu4cn/rust-lang-zh_CN.git
synced 2026-08-19 04:33:27 +08:00
Updated 'src/advanced_features/adv_types.md'.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
fn main() {
|
||||
let s1: str = "致以问候!";
|
||||
let s2: str = "最近过得怎么样?";
|
||||
let s1: &str = "致以问候!";
|
||||
let s2: &str = "最近过得怎么样?";
|
||||
|
||||
println! ("{}, {}", s1.len(), s2.len());
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
fn main() {
|
||||
print! ("永永 ");
|
||||
|
||||
loop {
|
||||
let res = loop {
|
||||
print! ("远远 ");
|
||||
}
|
||||
break
|
||||
};
|
||||
|
||||
println! ("{res:?}");
|
||||
}
|
||||
|
||||
@@ -5,16 +5,4 @@ fn main() {
|
||||
let y: Kilometers = 5;
|
||||
|
||||
assert_eq! (x, y);
|
||||
|
||||
type Thunk = Box<dyn Fn() + Send + 'static>;
|
||||
|
||||
let f: Thunk = Box::new(|| println! ("嗨"));
|
||||
|
||||
fn takes_long_type(f: Thunk) {
|
||||
// --跳过代码--
|
||||
}
|
||||
|
||||
fn returns_long_type() -> Thunk {
|
||||
// --跳过代码--
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user