/// Inserts a value into the scoped cell for the duration of the closure pub(super) fn set<F, R>(&self, t: &T, f: F) -> R where
F: FnOnce() -> R,
{ struct Reset<'a, T> {
cell: &'a Cell<*const T>,
prev: *const T,
}
impl<T> Drop for Reset<'_, T> { fn drop(&mutself) { self.cell.set(self.prev);
}
}
let prev = self.inner.get(); self.inner.set(t as *const _);
let _reset = Reset {
cell: &self.inner,
prev,
};
f()
}
/// Gets the value out of the scoped cell; pub(super) fn with<F, R>(&self, f: F) -> R where
F: FnOnce(Option<&T>) -> R,
{ let val = self.inner.get();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.