prompt_input

Trait StringPromptable

Source
pub trait StringPromptable {
    // Required method
    fn prompt(output: &str) -> Self;
}
Expand description

A trait that defines prompt functionality for obtaining user input as a String.

This trait allows any type that implements StringPromptable to provide a prompt for user input, making it easier to capture data of type String.

§Methods

  • prompt: Displays a prompt message to the user and returns the input as the type implementing the trait.

Required Methods§

Source

fn prompt(output: &str) -> Self

Displays a prompt message to the user and returns the input as the type that implements the trait.

§Parameters
  • output: The message that will be shown to the user.
§Examples
let name: String = String::prompt("What is your name? ");

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl StringPromptable for String

Source§

fn prompt(output: &str) -> Self

Implementors§