Fix lints from recent PR (#248)
parent
0f35aa450e
commit
41f72b2513
11
src/query.rs
11
src/query.rs
|
@ -1,12 +1,14 @@
|
||||||
use crate::{make_term, Schema};
|
use crate::{make_term, Schema};
|
||||||
use pyo3::{exceptions, prelude::*, types::PyAny, types::PyString, types::PyTuple};
|
use pyo3::{
|
||||||
|
exceptions, prelude::*, types::PyAny, types::PyString, types::PyTuple,
|
||||||
|
};
|
||||||
use tantivy as tv;
|
use tantivy as tv;
|
||||||
|
|
||||||
/// Custom Tuple struct to represent a pair of Occur and Query
|
/// Custom Tuple struct to represent a pair of Occur and Query
|
||||||
/// for the BooleanQuery
|
/// for the BooleanQuery
|
||||||
struct OccurQueryPair(Occur, Query);
|
struct OccurQueryPair(Occur, Query);
|
||||||
|
|
||||||
impl <'source> FromPyObject<'source> for OccurQueryPair {
|
impl<'source> FromPyObject<'source> for OccurQueryPair {
|
||||||
fn extract(ob: &'source PyAny) -> PyResult<Self> {
|
fn extract(ob: &'source PyAny) -> PyResult<Self> {
|
||||||
let tuple = ob.downcast::<PyTuple>()?;
|
let tuple = ob.downcast::<PyTuple>()?;
|
||||||
let occur = tuple.get_item(0)?.extract()?;
|
let occur = tuple.get_item(0)?.extract()?;
|
||||||
|
@ -16,7 +18,6 @@ impl <'source> FromPyObject<'source> for OccurQueryPair {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Tantivy's Occur
|
/// Tantivy's Occur
|
||||||
#[pyclass(frozen, module = "tantivy.tantivy")]
|
#[pyclass(frozen, module = "tantivy.tantivy")]
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -137,13 +138,13 @@ impl Query {
|
||||||
#[staticmethod]
|
#[staticmethod]
|
||||||
#[pyo3(signature = (subqueries))]
|
#[pyo3(signature = (subqueries))]
|
||||||
pub(crate) fn boolean_query(
|
pub(crate) fn boolean_query(
|
||||||
subqueries: Vec<(Occur, Query)>
|
subqueries: Vec<(Occur, Query)>,
|
||||||
) -> PyResult<Query> {
|
) -> PyResult<Query> {
|
||||||
let dyn_subqueries = subqueries
|
let dyn_subqueries = subqueries
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(occur, query)| (occur.into(), query.inner.box_clone()))
|
.map(|(occur, query)| (occur.into(), query.inner.box_clone()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let inner = tv::query::BooleanQuery::from(dyn_subqueries);
|
let inner = tv::query::BooleanQuery::from(dyn_subqueries);
|
||||||
|
|
||||||
Ok(Query {
|
Ok(Query {
|
||||||
|
|
Loading…
Reference in New Issue