pub struct Thunk(Rc<RefCell<ThunkRepr>>);
Expand description
A thunk is created for any value which requires non-strict
evaluation due to self-reference or lazy semantics (or both).
Every reference cycle involving Value
s will contain at least
one Thunk
.
Tuple Fields§
§0: Rc<RefCell<ThunkRepr>>
Implementations§
source§impl Thunk
impl Thunk
pub fn new_closure(lambda: Rc<Lambda>) -> Self
pub fn new_suspended(lambda: Rc<Lambda>, span: Span) -> Self
pub fn new_suspended_native( native: Box<dyn Fn() -> Result<Value, ErrorKind>>, ) -> Self
sourcepub fn new_suspended_call(callee: Value, arg: Value, span: Span) -> Self
pub fn new_suspended_call(callee: Value, arg: Value, span: Span) -> Self
Helper function to create a Thunk
that calls a function given as the
Value
callee
with the argument arg
when it is forced. This is
particularly useful in builtin implementations if the result of calling
a function does not need to be forced immediately, because e.g. it is
stored in an attribute set.
fn prepare_blackhole(&self, forced_at: Span) -> ThunkRepr
pub async fn force( myself: Thunk, co: GenCo, span: Span, ) -> Result<Value, ErrorKind>
pub async fn force_( myself: Thunk, co: &GenCo, span: Span, ) -> Result<Value, ErrorKind>
pub fn finalise(&self, stack: &[Value])
pub fn is_evaluated(&self) -> bool
pub fn is_suspended(&self) -> bool
sourcepub fn value(&self) -> Ref<'_, Value>
pub fn value(&self) -> Ref<'_, Value>
Returns a reference to the inner evaluated value of a thunk. It is an error to call this on a thunk that has not been forced, or is not otherwise known to be fully evaluated.
sourcefn unwrap_or_clone(self) -> Value
fn unwrap_or_clone(self) -> Value
Returns the inner evaluated value of a thunk, cloning it if the Rc has more than one strong reference. It is an error to call this on a thunk that has not been forced, or is not otherwise known to be fully evaluated.
pub fn upvalues(&self) -> Ref<'_, Upvalues>
pub fn upvalues_mut(&self) -> RefMut<'_, Upvalues>
sourcepub(crate) fn ptr_eq(&self, other: &Self) -> bool
pub(crate) fn ptr_eq(&self, other: &Self) -> bool
Do not use this without first reading and understanding
tvix/docs/value-pointer-equality.md
.
sourcepub(crate) fn debug_repr(&self) -> String
pub(crate) fn debug_repr(&self) -> String
Helper function to format thunks in observer output.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Thunk
impl !RefUnwindSafe for Thunk
impl !Send for Thunk
impl !Sync for Thunk
impl Unpin for Thunk
impl !UnwindSafe for Thunk
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more