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
impl Confirm
Sourcepub fn new(title: &str, default: bool) -> Self
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);Sourcepub fn start(&self) -> bool
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§
Auto Trait Implementations§
impl Freeze for Confirm
impl RefUnwindSafe for Confirm
impl Send for Confirm
impl Sync for Confirm
impl Unpin for Confirm
impl UnwindSafe for Confirm
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