pub struct ConflictingOptionError<'a> { /* private fields */ }Expand description
Error indicating that two or more options conflict with each other
This is a helper object for constructing an error message from a list of
conflicting option occurrences. An instance of this type can be created
using new or pick_from_indexes
and printed with report_error.
Implementations§
Source§impl<'a> ConflictingOptionError<'a>
impl<'a> ConflictingOptionError<'a>
Sourcepub fn new<T: Into<Vec<OptionOccurrence<'a>>>>(options: T) -> Self
pub fn new<T: Into<Vec<OptionOccurrence<'a>>>>(options: T) -> Self
Creates a new ConflictingOptionError from a list of conflicting options.
The vector should contain at least two elements, or the returned error object may panic when formatted.
Sourcepub fn pick_from_indexes<const N: usize>(
options: Vec<OptionOccurrence<'a>>,
indexes: [usize; N],
) -> Self
pub fn pick_from_indexes<const N: usize>( options: Vec<OptionOccurrence<'a>>, indexes: [usize; N], ) -> Self
Creates a new ConflictingOptionError with conflicting options
extracted from a vector.
This function retains only the options in the vector whose indexes are
specified in indexes. The other options are discarded.
The indexes may be specified in any order as they are sorted in this
function.
indexes should contain at least two elements, or the returned error
object may panic when formatted. This function panics immediately if
indexes contains a duplicate index.
This function is useful for constructing a ConflictingOptionError from
the result of parse_arguments.
After examining the OptionOccurrence vector returned by the function,
the caller can pick the indexes of the conflicting options and pass them
to this function.
For example, calling ConflictingOptionError::pick_from_indexes(vec![a, b, c, d, e], [3, 0]) is equivalent to ConflictingOptionError::new([a, d]).
Sourcepub fn options(&self) -> &[OptionOccurrence<'a>]
pub fn options(&self) -> &[OptionOccurrence<'a>]
Returns the list of conflicting options.
Trait Implementations§
Source§impl<'a> Clone for ConflictingOptionError<'a>
impl<'a> Clone for ConflictingOptionError<'a>
Source§fn clone(&self) -> ConflictingOptionError<'a>
fn clone(&self) -> ConflictingOptionError<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'a> Debug for ConflictingOptionError<'a>
impl<'a> Debug for ConflictingOptionError<'a>
Source§impl<'a> Display for ConflictingOptionError<'a>
impl<'a> Display for ConflictingOptionError<'a>
Source§impl<'a> Error for ConflictingOptionError<'a>
impl<'a> Error for ConflictingOptionError<'a>
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl<'a> From<&'a ConflictingOptionError<'a>> for Report<'a>
impl<'a> From<&'a ConflictingOptionError<'a>> for Report<'a>
Source§fn from(error: &'a ConflictingOptionError<'a>) -> Self
fn from(error: &'a ConflictingOptionError<'a>) -> Self
Source§impl<'a> From<ConflictingOptionError<'a>> for Vec<OptionOccurrence<'a>>
impl<'a> From<ConflictingOptionError<'a>> for Vec<OptionOccurrence<'a>>
Source§fn from(error: ConflictingOptionError<'a>) -> Self
fn from(error: ConflictingOptionError<'a>) -> Self
Source§impl From<ConflictingOptionError<'static>> for Error
impl From<ConflictingOptionError<'static>> for Error
Source§fn from(source: ConflictingOptionError<'static>) -> Self
fn from(source: ConflictingOptionError<'static>) -> Self
Source§impl<'a> From<Vec<OptionOccurrence<'a>>> for ConflictingOptionError<'a>
impl<'a> From<Vec<OptionOccurrence<'a>>> for ConflictingOptionError<'a>
Source§fn from(options: Vec<OptionOccurrence<'a>>) -> Self
fn from(options: Vec<OptionOccurrence<'a>>) -> Self
Creates a new ConflictingOptionError from a list of conflicting options.
The vector should contain at least two elements, or the returned error object may panic when formatted.
Source§impl<'a> PartialEq for ConflictingOptionError<'a>
impl<'a> PartialEq for ConflictingOptionError<'a>
impl<'a> Eq for ConflictingOptionError<'a>
impl<'a> StructuralPartialEq for ConflictingOptionError<'a>
Auto Trait Implementations§
impl<'a> Freeze for ConflictingOptionError<'a>
impl<'a> !RefUnwindSafe for ConflictingOptionError<'a>
impl<'a> !Send for ConflictingOptionError<'a>
impl<'a> !Sync for ConflictingOptionError<'a>
impl<'a> Unpin for ConflictingOptionError<'a>
impl<'a> UnsafeUnpin for ConflictingOptionError<'a>
impl<'a> !UnwindSafe for ConflictingOptionError<'a>
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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