projects
/
web.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
fda2235
)
read_ref doe not need to mutate
author
Ralf Jung
<post@ralfj.de>
Sun, 10 Mar 2019 19:29:45 +0000
(20:29 +0100)
committer
Ralf Jung
<post@ralfj.de>
Sun, 10 Mar 2019 19:29:47 +0000
(20:29 +0100)
thanks to @amosonn!
ralf/_posts/2018-04-05-a-formal-look-at-pinning.md
patch
|
blob
|
history
diff --git
a/ralf/_posts/2018-04-05-a-formal-look-at-pinning.md
b/ralf/_posts/2018-04-05-a-formal-look-at-pinning.md
index 72dccc18d5cbea0fd8931830160fb8335643dab3..5e51e7c747dbc01a0307a5f343b28e21cd27997c 100644
(file)
--- a/
ralf/_posts/2018-04-05-a-formal-look-at-pinning.md
+++ b/
ralf/_posts/2018-04-05-a-formal-look-at-pinning.md
@@
-68,11
+68,11
@@
impl SelfReferential {
fn init(mut self: Pin<SelfReferential>) {
let this : &mut SelfReferential = unsafe { Pin::get_mut(&mut self) };
// Set up self_ref to point to this.data.
fn init(mut self: Pin<SelfReferential>) {
let this : &mut SelfReferential = unsafe { Pin::get_mut(&mut self) };
// Set up self_ref to point to this.data.
- this.self_ref = &
mut
this.data as *const i32;
+ this.self_ref = &this.data as *const i32;
}
}
- fn read_ref(
mut
self: Pin<SelfReferential>) -> Option<i32> {
- let this : &
mut SelfReferential = unsafe { Pin::get_mut(&mut self) }
;
+ fn read_ref(self: Pin<SelfReferential>) -> Option<i32> {
+ let this : &
SelfReferential = &*self
;
// Dereference self_ref if it is non-NULL.
if this.self_ref == ptr::null() {
None
// Dereference self_ref if it is non-NULL.
if this.self_ref == ptr::null() {
None