Skip to content

Commit b945d69

Browse files
committed
cosmetic
1 parent 587ff42 commit b945d69

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

c19_advanced_traits/src/main.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl fmt::Display for Wrapper {
124124
}
125125
}
126126

127-
// alias for a lengthy type
127+
// alias for a lengthy type. Note Fn vs fn.
128128
type Thunk = Box<dyn Fn() + Send + 'static>;
129129

130130
fn takes_long_type(f: Thunk){
@@ -185,8 +185,14 @@ fn main() {
185185
let f: Thunk = Box::new(|| println!("aloha"));
186186
takes_long_type(f);
187187
returns_long_type()();
188+
189+
println!("6) DST (Dynamically Sized Type): why str is always &str.");
190+
// str is a DST (dynamically sized type) and must use a pointer-like (&str slice)
191+
let s1: &str = "Hellow there!";
192+
let s2 = "How's it going?";
193+
println!("s1 is {s1}, s2 is {s2}.");
188194

189-
println!("6) Never Type: loop/continue/panic! return ! (never type).
195+
println!("7) Never Type: loop/continue/panic! return ! (never type).
190196
// break returns () (unit type).");
191197
let mut c = 0;
192198
//
@@ -198,16 +204,11 @@ fn main() {
198204
break;
199205
}
200206
};
201-
println!("\n Press Ctrl+C after 3 secs to interrupt the following forever loop.");
207+
println!("\n Press Ctrl+C to interrupt the following forever loop.");
202208
thread::sleep(Duration::from_secs(3));
203-
204209
let b = loop {
205210
c += 1;
206211
print!("bever ");
207212
};
208213

209-
// str is a DST (dynamically sized type) and must use a pointer-like (&str slice)
210-
let s1: &str = "Hellow there!";
211-
let s2 = "How's it going?";
212-
213214
}

0 commit comments

Comments
 (0)