pub struct FormElement<T: Display, Q: Display> {
pub name: T,
pub description: Option<Q>,
}
Expand description
A structure to represent an individual option of a form.
Fields§
§name: T
§description: Option<Q>
Implementations§
Source§impl<T: Display, Q: Display> FormElement<T, Q>
impl<T: Display, Q: Display> FormElement<T, Q>
Sourcepub fn new(name: T, description: Option<Q>) -> Self
pub fn new(name: T, description: Option<Q>) -> Self
Examples found in repository?
examples/example.rs (lines 6-9)
3fn main() -> std::io::Result<()> {
4 let mut form: Vec<FormElement<_, bool>> = Vec::new();
5 for i in 0..100_usize {
6 form.push(FormElement::new(
7 char::from(65 + (i % 26_usize) as u8),
8 None,
9 ));
10 }
11 println!("{}", FormElement::run(&form)?.name);
12
13 Ok(())
14}
Sourcepub fn run<'a>(list: &'a [Self]) -> Result<&'a Self>
pub fn run<'a>(list: &'a [Self]) -> Result<&'a Self>
Runs the form, that is to display it and then check for a valid response from the user.
Examples found in repository?
examples/example.rs (line 11)
3fn main() -> std::io::Result<()> {
4 let mut form: Vec<FormElement<_, bool>> = Vec::new();
5 for i in 0..100_usize {
6 form.push(FormElement::new(
7 char::from(65 + (i % 26_usize) as u8),
8 None,
9 ));
10 }
11 println!("{}", FormElement::run(&form)?.name);
12
13 Ok(())
14}
Auto Trait Implementations§
impl<T, Q> Freeze for FormElement<T, Q>
impl<T, Q> RefUnwindSafe for FormElement<T, Q>where
T: RefUnwindSafe,
Q: RefUnwindSafe,
impl<T, Q> Send for FormElement<T, Q>
impl<T, Q> Sync for FormElement<T, Q>
impl<T, Q> Unpin for FormElement<T, Q>
impl<T, Q> UnwindSafe for FormElement<T, Q>where
T: UnwindSafe,
Q: UnwindSafe,
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