Enum jaq_syn::Arg

source ·
pub enum Arg<V = String, F = V> {
    Var(V),
    Fun(F),
}
Expand description

Argument of a definition, such as $v or f in def foo($v; f): ....

In jq, we can bind filters in three different ways:

  1. f as $x | ...
  2. def g($x): ...; g(f)
  3. def g(fx): ...; g(f)

In the first two cases, we bind the outputs of f to a variable $x. In the third case, we bind f to a filter fx

Variants§

§

Var(V)

binding to a variable

§

Fun(F)

binding to a filter

Implementations§

source§

impl<T> Arg<T, T>

source

pub fn map<U>(self, f: impl FnOnce(T) -> U) -> Arg<U, U>

Apply a function to both binding types.

source§

impl<V, F> Arg<V, F>

source

pub fn as_ref(&self) -> Arg<&V, &F>

Move references inward.

source§

impl<V: Deref, F: Deref> Arg<V, F>

source

pub fn as_deref(&self) -> Arg<&<V as Deref>::Target, &<F as Deref>::Target>

Move references inward, while deferencing content.

source§

impl<V, F> Arg<V, F>

source

pub fn new_var(name: V) -> Self

Create a variable argument with given name (without leading “$”).

source

pub fn new_filter(name: F) -> Self

Create a filter argument with given name.

source

pub fn is_var(&self) -> bool

True if the argument is a variable.

source§

impl<V: Deref, F: Deref> Arg<V, F>

source

pub fn get_var(&self) -> Option<&<V as Deref>::Target>

If the argument is a variable, return its name without leading “$”, otherwise None.

source

pub fn get_filter(&self) -> Option<&<F as Deref>::Target>

If the argument is a filter, return its name, otherwise None.

Trait Implementations§

source§

impl<V: Clone, F: Clone> Clone for Arg<V, F>

source§

fn clone(&self) -> Arg<V, F>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<V: Debug, F: Debug> Debug for Arg<V, F>

source§

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

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

impl<'de, V, F> Deserialize<'de> for Arg<V, F>
where V: Deserialize<'de>, F: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<V: PartialEq, F: PartialEq> PartialEq for Arg<V, F>

source§

fn eq(&self, other: &Arg<V, F>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<V, F> Serialize for Arg<V, F>
where V: Serialize, F: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<V: Eq, F: Eq> Eq for Arg<V, F>

source§

impl<V, F> StructuralEq for Arg<V, F>

source§

impl<V, F> StructuralPartialEq for Arg<V, F>

Auto Trait Implementations§

§

impl<V, F> RefUnwindSafe for Arg<V, F>

§

impl<V, F> Send for Arg<V, F>
where F: Send, V: Send,

§

impl<V, F> Sync for Arg<V, F>
where F: Sync, V: Sync,

§

impl<V, F> Unpin for Arg<V, F>
where F: Unpin, V: Unpin,

§

impl<V, F> UnwindSafe for Arg<V, F>
where F: UnwindSafe, V: 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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

§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,