pub enum Concrete {
Null,
Bool(bool),
Int(i64),
Float(f64),
String(Rc<NixString>),
Path(Box<SmolStr>),
List(Rc<NixList>),
Attrs(Rc<NixAttrs>),
Lambda(Rc<Closure>),
Builtin(Box<BuiltinFn>),
}Expand description
A demanded Nix value. Guaranteed NOT a Thunk at the TYPE level.
Unlike Value (which has a Thunk variant), Concrete is a separate
enum that DOES NOT HAVE a Thunk variant. The compiler rejects any attempt
to construct a Concrete from a thunk — the variant simply doesn’t exist.
The ONLY way to obtain a Concrete is through Value::demand().
let val: Value = eval_expr(expr, env)?; // might be Thunk
let c: Concrete = val.demand()?; // NOW guaranteed concrete
let n: i64 = c.as_int()?; // type-safe, thunk-freeVariants§
Null
Bool(bool)
Int(i64)
Float(f64)
String(Rc<NixString>)
Path(Box<SmolStr>)
List(Rc<NixList>)
Attrs(Rc<NixAttrs>)
Lambda(Rc<Closure>)
Builtin(Box<BuiltinFn>)
Implementations§
Source§impl Concrete
impl Concrete
Sourcepub fn into_value(self) -> Value
pub fn into_value(self) -> Value
Convert back to a Value (for APIs that still take Value).
Sourcepub fn to_value(&self) -> Value
pub fn to_value(&self) -> Value
Borrow as a Value reference. Constructs a temporary Value. Prefer specific accessors (as_bool, as_int, etc.) when possible.
Sourcepub fn as_nix_string(&self) -> Result<&NixString, EvalError>
pub fn as_nix_string(&self) -> Result<&NixString, EvalError>
Extract NixString ref — guaranteed no thunk.
Sourcepub fn as_list(&self) -> Result<&[Value], EvalError>
pub fn as_list(&self) -> Result<&[Value], EvalError>
Extract list ref — guaranteed no thunk at this level. Note: list ELEMENTS may still be lazy (Value, not Concrete).
Sourcepub fn as_attrs(&self) -> Result<&NixAttrs, EvalError>
pub fn as_attrs(&self) -> Result<&NixAttrs, EvalError>
Extract attrs ref — guaranteed no thunk at this level. Note: attr VALUES may still be lazy (Value, not Concrete).
Sourcepub fn as_string(&self) -> Result<&str, EvalError>
pub fn as_string(&self) -> Result<&str, EvalError>
Alias for as_str() — API parity with Value::as_string().
Sourcepub fn to_attrs(&self) -> Result<NixAttrs, EvalError>
pub fn to_attrs(&self) -> Result<NixAttrs, EvalError>
Extract owned NixAttrs — guaranteed no thunk at this level.
Sourcepub fn to_list(&self) -> Result<Vec<Value>, EvalError>
pub fn to_list(&self) -> Result<Vec<Value>, EvalError>
Extract owned list — guaranteed no thunk at this level.
Sourcepub fn coerce_to_path(&self, context: &str) -> Result<String, EvalError>
pub fn coerce_to_path(&self, context: &str) -> Result<String, EvalError>
Extract a filesystem path from Path or String.
Sourcepub fn to_nix_string(&self) -> Result<NixString, EvalError>
pub fn to_nix_string(&self) -> Result<NixString, EvalError>
Extract owned NixString (with context).
Sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
Check if value is a function (lambda or builtin).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Concrete
impl !Send for Concrete
impl !Sync for Concrete
impl !UnwindSafe for Concrete
impl Freeze for Concrete
impl Unpin for Concrete
impl UnsafeUnpin for Concrete
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.