You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I couldn't see an example of how to do this so I guessed it would just be calling dbase.get on the doc_id in the query result.
//adapted from tags example
let results = dbase.query_by_key("tags", b"cat").unwrap();
for result in results {
let doc_id = str::from_utf8(&result.doc_id).unwrap().to_owned();
println!("query result key: {:}", doc_id);
println!("tag value: {}", str::from_utf8(&result.value).unwrap().to_owned());
println!("get actual value {:?}", dbase.get::<Asset,_>(result.doc_id).ok().unwrap());
}
But I get the mutable borrow error:
error[E0502]: cannot borrow `dbase` as immutable because it is also borrowed as mutable
--> src/main.rs:123:44
|
118 | let results = dbase.query_by_key("tags", b"cat").unwrap();
| ----- mutable borrow occurs here
119 | for result in results {
| ------- mutable borrow later used here
...
123 | println!("get actual value {:?}", dbase.get::<Asset,_>(result.doc_id).ok().unwrap());
| ^^^^^ immutable borrow occurs here
The text was updated successfully, but these errors were encountered:
You are quite right that this use case was not considered when designing the API. For my purposes, I only needed the index values, and querying the full documents would come later as needed. It would require a different kind of iterator that returns the primary value along with the index values.
I couldn't see an example of how to do this so I guessed it would just be calling
dbase.get
on thedoc_id
in the query result.But I get the mutable borrow error:
The text was updated successfully, but these errors were encountered: