pub struct Questions(/* private fields */);Expand description
The questions for one call, each under an id. Answers come back under the same ids.
Ids are never sent to the model as meaning, so each question has to carry its own. Questions in one call share one read of the state and are answered in parallel, without seeing each other’s answers.
use typesafe::{Choice, Noul, Questions};
let questions = Questions::new()
.ask("billing", Noul::new("Is this ticket about billing?"))
.ask("tone", Choice::new("What is the customer's tone?").options(["calm", "angry"]));
assert_eq!(questions.len(), 2);Implementations§
Source§impl Questions
impl Questions
pub fn new() -> Self
Sourcepub fn ask(self, id: impl Into<String>, question: impl Into<Question>) -> Self
pub fn ask(self, id: impl Into<String>, question: impl Into<Question>) -> Self
Adds a question, builder style.
Sourcepub fn insert(
&mut self,
id: impl Into<String>,
question: impl Into<Question>,
) -> &mut Self
pub fn insert( &mut self, id: impl Into<String>, question: impl Into<Question>, ) -> &mut Self
Adds a question, for building in a loop.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn get(&self, id: &str) -> Option<&Question>
pub fn iter(&self) -> impl Iterator<Item = (&str, &Question)>
Trait Implementations§
Source§impl<K: Into<String>, Q: Into<Question>> Extend<(K, Q)> for Questions
impl<K: Into<String>, Q: Into<Question>> Extend<(K, Q)> for Questions
Source§fn extend<T: IntoIterator<Item = (K, Q)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, Q)>>(&mut self, iter: T)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
impl StructuralPartialEq for Questions
Auto Trait Implementations§
impl Freeze for Questions
impl RefUnwindSafe for Questions
impl Send for Questions
impl Sync for Questions
impl Unpin for Questions
impl UnsafeUnpin for Questions
impl UnwindSafe for Questions
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