Skip to main content

Confirm

Struct Confirm 

Source
pub struct Confirm { /* private fields */ }
Expand description

A yes-or-no field with an optional default answer.

Implementations§

Source§

impl Confirm

Source

pub fn new( key: FieldKey<ConfirmAnswer>, question: impl Into<String>, default: Option<bool>, ) -> Result<Self, FieldConfigError>

Creates a confirmation field with an optional default answer.

Source

pub fn labels(self, yes: impl Into<String>, no: impl Into<String>) -> Self

Sets the labels shown for yes and no. yes and no is plain text. Escape sequences in it are counted as ordinary characters when the prompt measures its cells, so a pre-styled string mis-aligns the field; style it through the prompt’s theme instead.

Source

pub fn button_alignment(self, alignment: Align) -> Self

Sets the horizontal alignment of the yes and no buttons.

The default is Align::Left. Center and right alignment position the buttons within the natural width of the question and description.

Source

pub fn description(self, description: impl Into<String>) -> Self

Sets supporting text shown below the question. description is plain text. Escape sequences in it are counted as ordinary characters when the prompt measures its cells, so a pre-styled string mis-aligns the field; style it through the prompt’s theme instead.

Source

pub fn help(self, help: impl Into<String>) -> Self

Sets the navigation hint shown beneath the choices. help is plain text. Escape sequences in it are counted as ordinary characters when the prompt measures its cells, so a pre-styled string mis-aligns the field; style it through the prompt’s theme instead.

Source

pub fn unanswered_message(self, message: impl Into<String>) -> Self

Sets the message shown when a confirmation without a default is unanswered.

Auto Trait Implementations§

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, 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.
Source§

impl<T> Field for T
where T: Sealed + 'static,