Confirm

Struct Confirm 

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

Represents a confirmation prompt with a title and a default value.

This struct provides a confirmation prompt to the user, allowing them to press ‘y’ or ‘n’ for yes or no. The default value is used if the user presses Enter without typing anything.

§Examples

use zenity::menu::input::Confirm;

// Create a new confirmation prompt with a title and a default value of 'yes'
let confirm = Confirm::new("Do you want to continue?", true);

// Start the confirmation prompt and get the user's response
let user_response = confirm.start();
if user_response {
    println!("User chose to continue.");
} else {
    println!("User chose not to continue.");
}

Implementations§

Source§

impl Confirm

Source

pub fn new(title: &str, default: bool) -> Self

Creates a new confirmation prompt with the specified title and default value.

§Arguments
  • title - The title or prompt for the confirmation.
  • default - The default value that can be accepted by pressing Enter.
§Returns

A new Confirm instance with the given title and default value.

§Example
use zenity::menu::input::Confirm;

// Create a new Confirmation instance with a title and default value
let confirm = Confirm::new("Do you want to proceed?", true);
Source

pub fn start(&self) -> bool

Starts the confirmation process, displaying the prompt and handling user input.

This method prompts the user for a yes/no confirmation, and returns the user’s choice.

§Returns

A boolean indicating the user’s choice.

§Example
use zenity::menu::input::Confirm;

// init and start directly
let confirm = Confirm::new("Do you want to proceed?", true).start();

Trait Implementations§

Source§

impl Default for Confirm

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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.