Term

Enum Term 

Source
pub enum Term<S> {
Show 18 variants Id, Recurse, Num(S), Str(Option<S>, Vec<StrPart<S, Self>>), Arr(Option<Box<Self>>), Obj(Vec<(Self, Option<Self>)>), Neg(Box<Self>), Pipe(Box<Self>, Option<Pattern<S>>, Box<Self>), BinOp(Box<Self>, BinaryOp, Box<Self>), Label(S, Box<Self>), Break(S), Fold(S, Box<Self>, Pattern<S>, Vec<Self>), TryCatch(Box<Self>, Option<Box<Self>>), IfThenElse(Vec<(Self, Self)>, Option<Box<Self>>), Def(Vec<Def<S, Self>>, Box<Self>), Call(S, Vec<Self>), Var(S), Path(Box<Self>, Path<Self>),
}
Expand description

Function from value to stream of values, such as .[] | add / length.

Variants§

§

Id

Identity, i.e. .

§

Recurse

Recursion (..)

§

Num(S)

Integer or floating-point number

§

Str(Option<S>, Vec<StrPart<S, Self>>)

String

This consists of an optional format filter starting with @ (such as @text), followed by quoted string parts (such as "Hello, \(.name)! \u263A").

§

Arr(Option<Box<Self>>)

Array, empty if None

§

Obj(Vec<(Self, Option<Self>)>)

Object, specifying its key-value pairs

§

Neg(Box<Self>)

Negation

§

Pipe(Box<Self>, Option<Pattern<S>>, Box<Self>)

Application, i.e. l | r if no string is given, else l as $x | r

§

BinOp(Box<Self>, BinaryOp, Box<Self>)

Sequence of binary operations, e.g. 1 + 2 - 3 * 4

§

Label(S, Box<Self>)

Control flow variable declaration, e.g. label $x | ...

§

Break(S)

Break out from control flow to location variable, e.g. break $x

§

Fold(S, Box<Self>, Pattern<S>, Vec<Self>)

reduce and foreach, e.g. reduce .[] as $x (0; .+$x)

§

TryCatch(Box<Self>, Option<Box<Self>>)

try and optional catch

§

IfThenElse(Vec<(Self, Self)>, Option<Box<Self>>)

If-then-else

§

Def(Vec<Def<S, Self>>, Box<Self>)

Local definition

§

Call(S, Vec<Self>)

Call to another filter, e.g. map(.+1)

§

Var(S)

Variable, such as $x (including leading ‘$’)

§

Path(Box<Self>, Path<Self>)

Path such as .a, .[][]."b", f[0]

Trait Implementations§

Source§

impl<S: Debug> Debug for Term<S>

Source§

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

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

impl<S> Default for Term<S>

Source§

fn default() -> Term<S>

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

Auto Trait Implementations§

§

impl<S> Freeze for Term<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for Term<S>
where S: RefUnwindSafe,

§

impl<S> Send for Term<S>
where S: Send,

§

impl<S> Sync for Term<S>
where S: Sync,

§

impl<S> Unpin for Term<S>
where S: Unpin,

§

impl<S> UnwindSafe for Term<S>
where S: UnwindSafe,

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> 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, 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.