mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-05-16 07:36:05 +02:00
Remove explicit derefs from shared ref slide (#2746)
When teaching I generally remove these. I emphasize that a reference can generally be used as if you have the referenced value directly, since in most cases you don't have to explicitly dereference a reference. On the next slide we show mutable references, and we need to use a deref when writing through a mutable reference, so I think that's the better place to point out the deref operator.
This commit is contained in:
parent
428f51a106
commit
c3450e7947
@ -14,10 +14,10 @@ fn main() {
|
||||
let b = 'B';
|
||||
|
||||
let mut r: &char = &a;
|
||||
dbg!(*r);
|
||||
dbg!(r);
|
||||
|
||||
r = &b;
|
||||
dbg!(*r);
|
||||
dbg!(r);
|
||||
}
|
||||
```
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user