Skip to main content

Option

Enum Option 

Source
#[non_exhaustive]
pub enum Option {
Show 20 variants AllExport, Clobber, CmdLine, ErrExit, Exec, Glob, HashOnDefinition, IgnoreEof, Interactive, Log, Login, Monitor, Notify, PipeFail, PosixlyCorrect, Stdin, Unset, Verbose, Vi, XTrace,
}
Expand description

Shell option

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

AllExport

Makes all variables exported when they are assigned.

§

Clobber

Allows overwriting and truncating an existing file with the > redirection.

§

CmdLine

Executes a command string specified as a command line argument.

§

ErrExit

Makes the shell to exit when a command returns a non-zero exit status.

§

Exec

Makes the shell to actually run commands.

§

Glob

Enables pathname expansion.

§

HashOnDefinition

Performs command search for each command in a function on its definition.

§

IgnoreEof

Prevents the interactive shell from exiting when the user enters an end-of-file.

§

Interactive

Enables features for interactive use.

§

Log

Allows function definition commands to be recorded in the command history.

§

Login

Sources the profile file on startup.

§

Monitor

Enables job control.

§

Notify

Automatically reports the results of asynchronous jobs.

§

PipeFail

Makes a pipeline reflect the exit status of the last failed component.

§

PosixlyCorrect

Disables most non-POSIX extensions.

§

Stdin

Reads commands from the standard input.

§

Unset

Expands unset variables to an empty string rather than erroring out.

§

Verbose

Echos the input before parsing and executing.

§

Vi

Enables vi-like command line editing.

§

XTrace

Prints expanded words during command execution.

Implementations§

Source§

impl Option

Source

pub const fn is_modifiable(self) -> bool

Whether this option can be modified by the set built-in.

Unmodifiable options can be set only on shell startup.

Source

pub const fn short_name(self) -> Option<(char, State)>

Returns the single-character option name.

This function returns a short name for the option and the state rendered by the name. The name can be converted back to Option with parse_short. Note that the result is None for options that do not have a short name.

Source

pub const fn long_name(self) -> &'static str

Returns the option name, all in lower case without punctuations.

This function returns a string like "allexport" and "exec". The name can be converted back to Option with parse_long.

Source§

impl Option

Source

pub fn iter() -> Iter

Creates an iterator that yields all available options in alphabetical order.

Trait Implementations§

Source§

impl<O: Into<EnumSet<Option>>> BitAnd<O> for Option

Source§

type Output = EnumSet<Option>

The resulting type after applying the & operator.
Source§

fn bitand(self, other: O) -> Self::Output

Performs the & operation. Read more
Source§

impl<O: Into<EnumSet<Option>>> BitOr<O> for Option

Source§

type Output = EnumSet<Option>

The resulting type after applying the | operator.
Source§

fn bitor(self, other: O) -> Self::Output

Performs the | operation. Read more
Source§

impl<O: Into<EnumSet<Option>>> BitXor<O> for Option

Source§

type Output = EnumSet<Option>

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: O) -> Self::Output

Performs the ^ operation. Read more
Source§

impl Clone for Option

Source§

fn clone(&self) -> Option

Returns a duplicate 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 Debug for Option

Source§

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

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

impl Display for Option

Prints the option name, all in lower case without punctuations.

Source§

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

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

impl EnumSetConstHelper for Option

Source§

const CONST_INIT_HELPER: __EnumSetInitHelper = __EnumSetInitHelper

The instance of the ConstInitHelper.
Source§

const CONST_OP_HELPER: __EnumSetOpHelper = __EnumSetOpHelper

The instance of the ConstOpHelper.
Source§

type ConstInitHelper = __EnumSetInitHelper

A helper type used to convert values to EnumSets at compile-time.
Source§

type ConstOpHelper = __EnumSetOpHelper

A helper type used to implement compile-time operations on enums.
Source§

impl EnumSetTypePrivate for Option

Source§

const ALL_BITS: Self::Repr = 1048575

A mask of bits that are valid in the bitset.
Source§

const BIT_WIDTH: u32 = 20u32

The largest bit used in the bitset.
Source§

const VARIANT_COUNT: u32 = 20u32

The number of variants in the bitset.
Source§

type Repr = u32

The underlying type used to store the bitset.
Source§

fn enum_into_u32(self) -> u32

Converts an enum of this type into its bit position.
Source§

unsafe fn enum_from_u32(val: u32) -> Self

Converts a bit position into an enum value.
Source§

unsafe fn enum_from_u32_checked(val: u32) -> Self

Converts a bit position into an enum value, with an debug_assert.
Source§

impl Extend<Option> for OptionSet

Source§

fn extend<T: IntoIterator<Item = Option>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl FromStr for Option

Parses an option name.

The input string should be a canonical option name, that is, all the characters should be lowercase and there should be no punctuations or other irrelevant characters. You can canonicalize the name before parsing it.

The option name may be abbreviated as long as it is an unambiguous prefix of a valid option name. For example, Option::from_str("clob") will return Ok(Clobber) like Option::from_str("clobber"). If the name is ambiguous, from_str returns Err(Ambiguous). A full option name is never considered ambiguous. For example, "log" is not ambiguous even though it is also a prefix of another valid option "login".

Note that new options may be added in the future, which can turn an unambiguous option name into an ambiguous one. You should use full option names for maximum compatibility.

Source§

type Err = FromStrError

The associated error which can be returned from parsing.
Source§

fn from_str(name: &str) -> Result<Self, FromStrError>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Option

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Not for Option

Source§

type Output = EnumSet<Option>

The resulting type after applying the ! operator.
Source§

fn not(self) -> Self::Output

Performs the unary ! operation. Read more
Source§

impl PartialEq<EnumSet<Option>> for Option

Source§

fn eq(&self, other: &EnumSet<Option>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Option

Source§

fn eq(&self, other: &Option) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<O: Into<EnumSet<Option>>> Sub<O> for Option

Source§

type Output = EnumSet<Option>

The resulting type after applying the - operator.
Source§

fn sub(self, other: O) -> Self::Output

Performs the - operation. Read more
Source§

impl Copy for Option

Source§

impl EnumSetType for Option

Source§

impl Eq for Option

Source§

impl StructuralPartialEq for Option

Auto Trait Implementations§

§

impl Freeze for Option

§

impl RefUnwindSafe for Option

§

impl Send for Option

§

impl Sync for Option

§

impl Unpin for Option

§

impl UnwindSafe for Option

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.