pub struct RefLock<T>where
T: ?Sized,{ /* private fields */ }
Expand description
Implementations§
Source§impl<T> RefLock<T>
impl<T> RefLock<T>
Sourcepub fn new(t: T) -> RefLock<T>
pub fn new(t: T) -> RefLock<T>
Examples found in repository?
examples/basic.rs (line 95)
84fn get_running_project(xml: &str, system: Rc<StdSystem<C>>) -> EnvArena {
85 EnvArena::new(|mc| {
86 let parser = ast::Parser::default();
87 let ast = parser.parse(xml).unwrap();
88 assert_eq!(ast.roles.len(), 1); // this should be handled more elegantly in practice - for the sake of this example, we only allow one role
89
90 let (bytecode, init_info, locs, _) = ByteCode::compile(&ast.roles[0]).unwrap();
91
92 let mut proj = Project::from_init(mc, &init_info, Rc::new(bytecode), Settings::default(), system);
93 proj.input(mc, Input::Start); // this is equivalent to clicking the green flag button
94
95 Env { proj: Gc::new(mc, RefLock::new(proj)), locs }
96 })
97}
pub fn into_inner(self) -> T
pub fn take(&self) -> Twhere
T: Default,
Source§impl<T> RefLock<T>where
T: ?Sized,
impl<T> RefLock<T>where
T: ?Sized,
pub fn as_ptr(&self) -> *mut T
pub fn borrow<'a>(&'a self) -> Ref<'a, T>
pub fn try_borrow<'a>(&'a self) -> Result<Ref<'a, T>, BorrowError>
Sourcepub unsafe fn as_ref_cell(&self) -> &RefCell<T>
pub unsafe fn as_ref_cell(&self) -> &RefCell<T>
Access the wrapped RefCell
.
§Safety
In order to maintain the invariants of the garbage collector, no new Gc
pointers may be adopted by this type as a result of the interior mutability
afforded by directly accessing the inner RefCell
, unless the write barrier for the containing Gc
pointer is invoked manuall
before collection is triggered.
pub fn get_mut(&mut self) -> &mut T
Trait Implementations§
Source§impl<'gc, T> Collect for RefLock<T>where
T: Collect + 'gc,
impl<'gc, T> Collect for RefLock<T>where
T: Collect + 'gc,
Source§fn needs_trace() -> bool
fn needs_trace() -> bool
As an optimization, if this type can never hold a
Gc
pointer and trace
is unnecessary
to call, you may implement this method and return false. The default implementation returns
true, signaling that Collect::trace
must be called.Source§fn trace(&self, cc: &Collection)
fn trace(&self, cc: &Collection)
Must call
Collect::trace
on all held Gc
pointers. If this type holds inner types that
implement Collect
, a valid implementation would simply call Collect::trace
on all the
held values to ensure this.Source§impl<T> Ord for RefLock<T>
impl<T> Ord for RefLock<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T> PartialOrd for RefLock<T>where
T: PartialOrd + ?Sized,
impl<T> PartialOrd for RefLock<T>where
T: PartialOrd + ?Sized,
impl<T> Eq for RefLock<T>
impl<T> StructuralPartialEq for RefLock<T>where
T: ?Sized,
Auto Trait Implementations§
impl<T> !Freeze for RefLock<T>
impl<T> !RefUnwindSafe for RefLock<T>
impl<T> Send for RefLock<T>
impl<T> !Sync for RefLock<T>
impl<T> Unpin for RefLock<T>
impl<T> UnwindSafe for RefLock<T>where
T: UnwindSafe + ?Sized,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more