pub struct Opt {
pub opt: String,
pub meta: OptMeta,
pub required: bool,
}Expand description
Command line option that takes a value.
Fields§
§opt: StringThe option as typed on the command line, e.g., -h or --help. If
it can be used in the --name=value format, then this should be
--name (though this is subject to change).
meta: OptMeta§required: boolImplementations§
Trait Implementations§
Source§impl<'v> AllocValue<'v> for Opt
impl<'v> AllocValue<'v> for Opt
Source§impl Allocative for Opt
impl Allocative for Opt
Source§impl<'pst> ProvidesStaticType<'pst> for Opt
impl<'pst> ProvidesStaticType<'pst> for Opt
Source§type StaticType = Opt
type StaticType = Opt
Source§impl<'v> Serialize for Optwhere
Self: StarlarkValue<'v>,
impl<'v> Serialize for Optwhere
Self: StarlarkValue<'v>,
Source§impl<'v> StarlarkValue<'v> for Opt
impl<'v> StarlarkValue<'v> for Opt
Source§const TYPE: &'static str = "Opt"
const TYPE: &'static str = "Opt"
Return a string describing the type of self, as returned by the type()
function. Read more
Source§type Canonical = Opt
type Canonical = Opt
Two implementations of
StarlarkValue are considered to have the same type,
if Canonical field points to the same type. Read moreSource§fn get_type_value_static() -> FrozenStringValue
fn get_type_value_static() -> FrozenStringValue
Like
TYPE, but returns a reusable FrozenStringValue
pointer to it. This function deliberately doesn’t take a heap,
as it would not be performant to allocate a new value each time. Read moreSource§fn get_type_starlark_repr() -> Ty
fn get_type_starlark_repr() -> Ty
Return a string that is the representation of a type that a user would use in
type annotations. This often will be the same as
Self::TYPE, but in
some instances it might be slightly different than what is returned by TYPE. Read moreSource§fn get_methods() -> Option<&'static Methods>where
Self: Sized,
fn get_methods() -> Option<&'static Methods>where
Self: Sized,
Get the members associated with this type, accessible via
this_type.x.
These members will have dir/getattr/hasattr properly implemented,
so it is the preferred way to go if possible. See
MethodsStatic for an example of how
to define this method.Source§fn documentation(&self) -> DocItemwhere
Self: Sized,
fn documentation(&self) -> DocItemwhere
Self: Sized,
Return the documentation for this value. Read more
Source§fn typechecker_ty(&self) -> Option<Ty>
fn typechecker_ty(&self) -> Option<Ty>
Type of this instance for typechecker.
Note this can be more precise than generic type.
Source§fn collect_repr(&self, collector: &mut String)
fn collect_repr(&self, collector: &mut String)
Return a string representation of self, as returned by the
repr() function.
Defaults to the Display instance - which should be fine for nearly all types.
In many cases the repr() representation will also be a Starlark expression
for creating the value. Read moreSource§fn collect_repr_cycle(&self, collector: &mut String)
fn collect_repr_cycle(&self, collector: &mut String)
Invoked to print
repr when a cycle is the object stack is detected.Source§fn name_for_call_stack(&self, me: Value<'v>) -> String
fn name_for_call_stack(&self, me: Value<'v>) -> String
String used when printing call stack.
repr(self) by default.Source§fn to_bool(&self) -> bool
fn to_bool(&self) -> bool
Convert self to a boolean, as returned by the bool() function.
The default implementation returns
true.Source§fn write_hash(&self, hasher: &mut StarlarkHasher) -> Result<(), Error>
fn write_hash(&self, hasher: &mut StarlarkHasher) -> Result<(), Error>
Return a hash data for self to be used when self is placed as a key in a
Dict.
Return an Err if there is no hash for this value (e.g. list).
Must be stable between frozen and non-frozen values.Source§fn invoke(
&self,
_me: Value<'v>,
_args: &Arguments<'v, '_>,
_eval: &mut Evaluator<'v, '_, '_>,
) -> Result<Value<'v>, Error>
fn invoke( &self, _me: Value<'v>, _args: &Arguments<'v, '_>, _eval: &mut Evaluator<'v, '_, '_>, ) -> Result<Value<'v>, Error>
Directly invoke a function.
The number of
named and names arguments are guaranteed to be equal. Read moreSource§fn at(&self, index: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>, Error>
fn at(&self, index: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>, Error>
Return the result of
a[index] if a is indexable.Source§fn at2(
&self,
_index0: Value<'v>,
_index1: Value<'v>,
_heap: &'v Heap,
_private: Private,
) -> Result<Value<'v>, Error>
fn at2( &self, _index0: Value<'v>, _index1: Value<'v>, _heap: &'v Heap, _private: Private, ) -> Result<Value<'v>, Error>
Return the result of
a[index0, index1] if a is indexable by two parameters.Source§fn slice(
&self,
_start: Option<Value<'v>>,
_stop: Option<Value<'v>>,
_stride: Option<Value<'v>>,
_heap: &'v Heap,
) -> Result<Value<'v>, Error>
fn slice( &self, _start: Option<Value<'v>>, _stop: Option<Value<'v>>, _stride: Option<Value<'v>>, _heap: &'v Heap, ) -> Result<Value<'v>, Error>
Extract a slice of the underlying object if the object is indexable. The
result will be object between
start and stop (both of them are
added length() if negative and then clamped between 0 and length()).
stride indicates the direction. Read moreSource§fn iterate_collect(&self, _heap: &'v Heap) -> Result<Vec<Value<'v>>, Error>
fn iterate_collect(&self, _heap: &'v Heap) -> Result<Vec<Value<'v>>, Error>
Implement iteration over the value of this container by providing
the values in a
Vec.Source§unsafe fn iterate(
&self,
_me: Value<'v>,
heap: &'v Heap,
) -> Result<Value<'v>, Error>
unsafe fn iterate( &self, _me: Value<'v>, heap: &'v Heap, ) -> Result<Value<'v>, Error>
Returns an iterator over the value of this container if this value holds
an iterable container. Read more
Source§unsafe fn iter_size_hint(&self, _index: usize) -> (usize, Option<usize>)
unsafe fn iter_size_hint(&self, _index: usize) -> (usize, Option<usize>)
Returns the size hint for the iterator.
Source§unsafe fn iter_next(&self, _index: usize, _heap: &'v Heap) -> Option<Value<'v>>
unsafe fn iter_next(&self, _index: usize, _heap: &'v Heap) -> Option<Value<'v>>
Yield the next value from the iterator. Read more
Source§fn length(&self) -> Result<i32, Error>
fn length(&self) -> Result<i32, Error>
Returns the length of the value, if this value is a sequence.
Source§fn get_attr(&self, _attribute: &str, _heap: &'v Heap) -> Option<Value<'v>>
fn get_attr(&self, _attribute: &str, _heap: &'v Heap) -> Option<Value<'v>>
Get an attribute for the current value as would be returned by dotted
expression (i.e.
a.attribute). Read moreSource§fn get_attr_hashed(
&self,
attribute: Hashed<&str>,
heap: &'v Heap,
) -> Option<Value<'v>>
fn get_attr_hashed( &self, attribute: Hashed<&str>, heap: &'v Heap, ) -> Option<Value<'v>>
A version of
get_attr which takes BorrowHashed<str> instead of &str,
thus implementation may reuse the hash of the string if this is called
repeatedly with the same string. Read moreSource§fn has_attr(&self, attribute: &str, heap: &'v Heap) -> bool
fn has_attr(&self, attribute: &str, heap: &'v Heap) -> bool
Return true if an attribute of name
attribute exists for the current
value. Read moreSource§fn dir_attr(&self) -> Vec<String>
fn dir_attr(&self) -> Vec<String>
Return a vector of string listing all attribute of the current value. Read more
Source§fn is_in(&self, other: Value<'v>) -> Result<bool, Error>
fn is_in(&self, other: Value<'v>) -> Result<bool, Error>
Tell whether
other is in the current value, if it is a container. Read moreSource§fn plus(&self, _heap: &'v Heap) -> Result<Value<'v>, Error>
fn plus(&self, _heap: &'v Heap) -> Result<Value<'v>, Error>
Apply the
+ unary operator to the current value. Read moreSource§fn minus(&self, _heap: &'v Heap) -> Result<Value<'v>, Error>
fn minus(&self, _heap: &'v Heap) -> Result<Value<'v>, Error>
Apply the
- unary operator to the current value. Read moreSource§fn radd(
&self,
_lhs: Value<'v>,
_heap: &'v Heap,
) -> Option<Result<Value<'v>, Error>>
fn radd( &self, _lhs: Value<'v>, _heap: &'v Heap, ) -> Option<Result<Value<'v>, Error>>
Add with the arguments the other way around.
Normal
add should return None in order for it to be evaluated.Source§fn sub(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>, Error>
fn sub(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>, Error>
Subtract
other from the current value. Read moreSource§fn rmul(
&self,
lhs: Value<'v>,
heap: &'v Heap,
) -> Option<Result<Value<'v>, Error>>
fn rmul( &self, lhs: Value<'v>, heap: &'v Heap, ) -> Option<Result<Value<'v>, Error>>
Called on
rhs of lhs * rhs when lhs.mul returns None.Source§fn mul(
&self,
_rhs: Value<'v>,
_heap: &'v Heap,
) -> Option<Result<Value<'v>, Error>>
fn mul( &self, _rhs: Value<'v>, _heap: &'v Heap, ) -> Option<Result<Value<'v>, Error>>
Multiply the current value with
other. Read moreSource§fn div(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>, Error>
fn div(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>, Error>
Divide the current value by
other. Always results in a float value. Read moreSource§fn percent(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>, Error>
fn percent(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>, Error>
Apply the percent operator between the current value and
other. Usually used on
strings, as per
the Starlark spec. Read moreSource§fn floor_div(
&self,
other: Value<'v>,
_heap: &'v Heap,
) -> Result<Value<'v>, Error>
fn floor_div( &self, other: Value<'v>, _heap: &'v Heap, ) -> Result<Value<'v>, Error>
Floor division between the current value and
other. Read moreSource§fn bit_and(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>, Error>
fn bit_and(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>, Error>
Bitwise
& operator.Source§fn bit_or(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>, Error>
fn bit_or(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>, Error>
Bitwise
| operator. Read moreSource§fn bit_xor(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>, Error>
fn bit_xor(&self, other: Value<'v>, _heap: &'v Heap) -> Result<Value<'v>, Error>
Bitwise
^ operator.Source§fn left_shift(
&self,
other: Value<'v>,
_heap: &'v Heap,
) -> Result<Value<'v>, Error>
fn left_shift( &self, other: Value<'v>, _heap: &'v Heap, ) -> Result<Value<'v>, Error>
Bitwise
<< operator.Source§fn right_shift(
&self,
other: Value<'v>,
_heap: &'v Heap,
) -> Result<Value<'v>, Error>
fn right_shift( &self, other: Value<'v>, _heap: &'v Heap, ) -> Result<Value<'v>, Error>
Bitwise
>> operator.Source§fn rbin_op_ty(_lhs: &TyBasic, _op: TypingBinOp) -> Option<Ty>
fn rbin_op_ty(_lhs: &TyBasic, _op: TypingBinOp) -> Option<Ty>
Typecheck
lhs op this.Source§fn export_as(
&self,
_variable_name: &str,
_eval: &mut Evaluator<'v, '_, '_>,
) -> Result<(), Error>
fn export_as( &self, _variable_name: &str, _eval: &mut Evaluator<'v, '_, '_>, ) -> Result<(), Error>
Called when exporting a value under a specific name,
Source§fn set_at(&self, _index: Value<'v>, _new_value: Value<'v>) -> Result<(), Error>
fn set_at(&self, _index: Value<'v>, _new_value: Value<'v>) -> Result<(), Error>
Set the value at
index with the new value. Read moreSource§fn set_attr(&self, attribute: &str, _new_value: Value<'v>) -> Result<(), Error>
fn set_attr(&self, attribute: &str, _new_value: Value<'v>) -> Result<(), Error>
Set the attribute named
attribute of the current value to
value (e.g. a.attribute = value).Source§fn provide(&'v self, demand: &mut Demand<'_, 'v>)
fn provide(&'v self, demand: &mut Demand<'_, 'v>)
Dynamically provide values based on type. Read more
Source§fn try_freeze_static(&self) -> Option<FrozenValue>
fn try_freeze_static(&self) -> Option<FrozenValue>
When freezing, this function is called on mutable value to return
statically allocated singleton value if possible. Read more
Source§impl<'v> UnpackValue<'v> for Opt
impl<'v> UnpackValue<'v> for Opt
Source§fn unpack_value_opt(value: Value<'v>) -> Option<Self>where
Self::Error: UnpackValueErrorInfallible,
fn unpack_value_opt(value: Value<'v>) -> Option<Self>where
Self::Error: UnpackValueErrorInfallible,
Unpack a value if unpacking is infallible.
Source§fn unpack_value_err(value: Value<'v>) -> Result<Self, Error>
fn unpack_value_err(value: Value<'v>) -> Result<Self, Error>
Unpack a value, but return error instead of
None if unpacking fails.impl Eq for Opt
impl StructuralPartialEq for Opt
Auto Trait Implementations§
impl Freeze for Opt
impl RefUnwindSafe for Opt
impl Send for Opt
impl Sync for Opt
impl Unpin for Opt
impl UnwindSafe for Opt
Blanket Implementations§
Source§impl<'a, T> AnyLifetime<'a> for Twhere
T: ProvidesStaticType<'a> + 'a + ?Sized,
impl<'a, T> AnyLifetime<'a> for Twhere
T: ProvidesStaticType<'a> + 'a + ?Sized,
Source§fn static_type_id() -> TypeId
fn static_type_id() -> TypeId
Must return the
TypeId of Self but where the lifetimes are changed
to 'static. Must be consistent with static_type_of.Source§fn static_type_of(&self) -> TypeId
fn static_type_of(&self) -> TypeId
Must return the
TypeId of Self but where the lifetimes are changed
to 'static. Must be consistent with static_type_id. Must not
consult the self parameter in any way.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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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>
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 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>
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