pub struct Questions<A: Answers> { /* private fields */ }Expand description
The question set of a named set: the struct A, which derives Answers.
The type A selects the questions, so Questions takes no data. Each question is a constant,
and cargo check validates it. Questions makes its questions for each request, and again to
read the answers.
§Examples
use system2::prelude::*;
use system2::NoulAnswer;
#[derive(Debug, Answers)]
struct Triage {
#[system2(question = noul!("Is the ticket urgent?"))]
urgent: NoulAnswer,
#[system2(question = noul!("Is the customer angry?"))]
angry: NoulAnswer,
}
// the struct is the caller's, so it can have methods
impl Triage {
fn needs_a_call(&self) -> bool {
self.urgent.is_likely() && self.angry.is_likely()
}
}
const TRIAGE: Questions<Triage> = Questions::new();
let triage = TRIAGE.ask("The site is down again.").await?;
if triage.needs_a_call() { /* … */ }
let triage: Triage = Questions::new().ask("The site is down again.").await?;Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<A> Forget for Questions<A>
impl<A> Freeze for Questions<A>
impl<A> Move for Questions<A>
impl<A> RefUnwindSafe for Questions<A>
impl<A> Send for Questions<A>
impl<A> Sync for Questions<A>
impl<A> Unpin for Questions<A>
impl<A> UnsafeUnpin for Questions<A>
impl<A> UnwindSafe for Questions<A>
Blanket Implementations§
Source§impl<Q> Ask for Qwhere
Q: QuestionSet,
impl<Q> Ask for Qwhere
Q: QuestionSet,
Source§impl<Q> Ask for Qwhere
Q: QuestionSet,
impl<Q> Ask for Qwhere
Q: QuestionSet,
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