oscourse-tsinghua / rcore_plus

Rust version of THU uCore OS. Linux compatible.
MIT License
172 stars 26 forks source link

What's the meaning of '&*'? #5

Closed chyyuu closed 4 years ago

chyyuu commented 5 years ago
......
    fn force_get<'a>(&'a self) -> &'a T {
        match unsafe { &*self.data.get() }.as_ref() {
            None    => unsafe { unreachable() },
            Some(p) => p,
        }
    }

What's the meaning of '&*'? @wangrunji0408

wangrunji0408 commented 5 years ago

Cast a *mut T to &T. * dereference a raw pointer to an owned value, then & get its ref.