pub struct Answer { /* private fields */ }Expand description
A complete set of matching situations.
Complete, not ranked: every situation satisfying the query is here, so counting is meaningful. Iterate it
directly, or read Answer::ids.
Implementations§
Source§impl Answer
impl Answer
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
How many situations matched.
Examples found in repository?
examples/quickstart.rs (line 30)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let docs = [
8 "Morty Shade defeated Wallace Gale at Ecruteak City during the Indigo Invitational in 2025.",
9 "Bea Strike defeated Iris Draco at Ecruteak City during the Indigo Invitational in 2025.",
10 "Juan Tide defeated Cynthia Ward at Ecruteak City during the Indigo Invitational in 2026.",
11 "A habitat survey recorded Aggron near Sootopolis City at an elevation of 1082 m.",
12 "A habitat survey recorded Salamence near Sootopolis City at an elevation of 2369 m.",
13 "A habitat survey recorded Milotic near Sootopolis City at an elevation of 340 m.",
14 "Milotic is not permitted in Series 1 play for the 2025 season.",
15 "Metagross is permitted in Series 4 play for the 2026 season.",
16 ];
17
18 let db = SteelDb::ingest(docs)?;
19 println!("indexed {} situations", db.len());
20
21 println!("\nyou can ask about:");
22 for c in db.categories() {
23 println!(" {:<14} {}", c.wildcard(), c.words.iter().take(4).cloned().collect::<Vec<_>>().join(", "));
24 }
25
26 // use a category the corpus actually produced — see the list printed above
27 let q = "(and elevation/* (not state/negated))";
28 match db.query(q) {
29 Ok(a) => {
30 println!("\n{q} -> {} situations", a.len());
31 for (id, text) in db.resolve(&a).take(2) {
32 // chars(), not a byte slice: `&text[..n]` panics mid-character
33 println!(" [{id}] {}", text.chars().take(56).collect::<String>());
34 }
35 }
36 Err(r) => println!("\n{r}"),
37 }
38
39 // a category this corpus does not have — refused, not answered with an empty list
40 match db.query("survey/*") {
41 Ok(_) => println!("\nunexpected: survey is not a category here"),
42 Err(r) => println!("\n{r}"),
43 }
44
45 match db.query("gene/brca1") {
46 Ok(_) => println!("\nunexpected: that should not exist"),
47 Err(r) => println!("\n{r}"),
48 }
49
50 println!("\nbelief in a denied claim: {}", db.belief("state/negated"));
51 Ok(())
52}pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl IntoIterator for Answer
impl IntoIterator for Answer
Auto Trait Implementations§
impl Freeze for Answer
impl RefUnwindSafe for Answer
impl Send for Answer
impl Sync for Answer
impl Unpin for Answer
impl UnsafeUnpin for Answer
impl UnwindSafe for Answer
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.