-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rust #2
Comments
rust 中可以实现下面的方法吗? pub trait Foo {
fn bar(self: Rc<dyn Foo>) -> Rc<dyn Foo> {
Rc::new(BarFoo { foo: self.clone() })
}
} |
how to do placememt new.
|
空指针在 rust 中的实现: type EmptyPtr<T> = Option<Rc<T>>;
impl<T> EmptyPtr<T> {
pub fn is_null(&self) -> bool {
self.is_none()
}
pub fn set_null(&mut self) {
self.take()
// std::mem::replace(&mut self, None)
}
} unsafe rust, raw pointer |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: