pub struct Choice { /* private fields */ }Expand description
A single selectable option: pure data carrying an id, a human label, an optional annotation line, and whether it is the recommended default.
Implementations§
Source§impl Choice
impl Choice
Sourcepub fn new(id: impl Into<ChoiceId>, label: impl Into<String>) -> Self
pub fn new(id: impl Into<ChoiceId>, label: impl Into<String>) -> Self
Create a choice from an id and human-readable label.
Sourcepub fn with_annotation(self, annotation: impl Into<String>) -> Self
pub fn with_annotation(self, annotation: impl Into<String>) -> Self
Attach a secondary annotation line (for example detected in dev-deps).
Sourcepub const fn recommended(self) -> Self
pub const fn recommended(self) -> Self
Mark this choice as the recommended default.
In PromptMode::NonInteractive
a select resolves to the recommended choice, and an interactive prompt
offers it when the answer is left blank.
Sourcepub fn annotation(&self) -> Option<&str>
pub fn annotation(&self) -> Option<&str>
The optional annotation line, if any.
Sourcepub const fn is_recommended(&self) -> bool
pub const fn is_recommended(&self) -> bool
Whether this choice is the recommended default.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Choice
impl<'de> Deserialize<'de> for Choice
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Choice
impl StructuralPartialEq for Choice
Auto Trait Implementations§
impl Freeze for Choice
impl RefUnwindSafe for Choice
impl Send for Choice
impl Sync for Choice
impl Unpin for Choice
impl UnsafeUnpin for Choice
impl UnwindSafe for Choice
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.