Skip to main content

Record

Struct Record 

Source
pub struct Record<'ast> { /* private fields */ }
Expand description

A Nickel record being constructed

Implementations§

Source§

impl<'ast> Record<'ast>

Source

pub fn new() -> Self

Make a new, empty record builder

Source

pub fn field(self, name: impl AsRef<str>) -> Field<'ast, Record<'ast>>

Start constructing a field with the given name

Source

pub fn fields<I, It>(self, alloc: &'ast AstAlloc, fields: It) -> Self
where I: Into<Field<'ast, Complete<'ast>>>, It: IntoIterator<Item = I>,

Attach possibly multiple fields to this record

Source

pub fn include(self, ident: LocIdent) -> Self

Adds an include expression (define a field by taking it from the outer environment).

Source

pub fn include_with_metadata( self, ident: LocIdent, metadata: FieldMetadata<'ast>, ) -> Self

Adds an include expression with associated metadata.

Source

pub fn path<It, I>(self, path: It) -> Field<'ast, Record<'ast>>
where I: AsRef<str>, It: IntoIterator<Item = I>,

Start constructing a field at the given path

Source

pub fn open(self) -> Self

Mark this record as “open” when used as a contract

Source

pub fn set_open(self, open: bool) -> Self

Mark this record as “open” when used as a contract, depending on the value of open

Source

pub fn build(self, alloc: &'ast AstAlloc) -> Ast<'ast>

Finalize the record and turn it into a super::Ast

Source

pub fn from_iterator<I, It>(alloc: &'ast AstAlloc, fields: It) -> Self
where I: Into<Field<'ast, Complete<'ast>>>, It: IntoIterator<Item = I>,

Creates a record from an iterator of finalized fields.

We can’t implement FromIterator for Record because we need to provide an additional allocator.

Trait Implementations§

Source§

impl<'ast> Debug for Record<'ast>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'ast> Default for Record<'ast>

Source§

fn default() -> Record<'ast>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'ast> Freeze for Record<'ast>

§

impl<'ast> RefUnwindSafe for Record<'ast>

§

impl<'ast> Send for Record<'ast>

§

impl<'ast> Sync for Record<'ast>

§

impl<'ast> Unpin for Record<'ast>

§

impl<'ast> UnsafeUnpin for Record<'ast>

§

impl<'ast> UnwindSafe for Record<'ast>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T, U> ExactFrom<T> for U
where U: TryFrom<T>,

Source§

fn exact_from(value: T) -> U

Source§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

Source§

fn exact_into(self) -> U

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

Source§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

Source§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

Source§

impl<T> ToDebugString for T
where T: Debug,

Source§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

§Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
Source§

impl<T, U> TryConvert<'_, T> for U
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

Source§

fn try_convert( _: &AstAlloc, from: T, ) -> Result<U, <U as TryConvert<'_, T>>::Error>

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

Source§

fn wrapping_into(self) -> U