mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 12:27:13 +02:00
Prompt: relax lifetime constraints
This commit is contained in:
parent
c1a132fa06
commit
e30c24b5bf
3 changed files with 20 additions and 19 deletions
|
@ -144,18 +144,19 @@ impl ValueView for Document<'_> {
|
||||||
use crate::update::new::document::Document as DocumentTrait;
|
use crate::update::new::document::Document as DocumentTrait;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ParseableDocument<'doc, D> {
|
pub struct ParseableDocument<'a, 'doc, D: DocumentTrait<'a> + Debug> {
|
||||||
document: D,
|
document: D,
|
||||||
doc_alloc: &'doc Bump,
|
doc_alloc: &'doc Bump,
|
||||||
|
_marker: std::marker::PhantomData<&'a ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'doc, D> ParseableDocument<'doc, D> {
|
impl<'a, 'doc, D: DocumentTrait<'a> + Debug> ParseableDocument<'a, 'doc, D> {
|
||||||
pub fn new(document: D, doc_alloc: &'doc Bump) -> Self {
|
pub fn new(document: D, doc_alloc: &'doc Bump) -> Self {
|
||||||
Self { document, doc_alloc }
|
Self { document, doc_alloc, _marker: std::marker::PhantomData }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'doc, D: DocumentTrait<'doc> + Debug> ObjectView for ParseableDocument<'doc, D> {
|
impl<'a, D: DocumentTrait<'a> + Debug> ObjectView for ParseableDocument<'a, '_, D> {
|
||||||
fn as_value(&self) -> &dyn ValueView {
|
fn as_value(&self) -> &dyn ValueView {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -195,7 +196,7 @@ impl<'doc, D: DocumentTrait<'doc> + Debug> ObjectView for ParseableDocument<'doc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'doc, D: DocumentTrait<'doc> + Debug> ValueView for ParseableDocument<'doc, D> {
|
impl<'a, D: DocumentTrait<'a> + Debug> ValueView for ParseableDocument<'a, '_, D> {
|
||||||
fn as_debug(&self) -> &dyn Debug {
|
fn as_debug(&self) -> &dyn Debug {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,10 +121,10 @@ impl<D: ObjectView> ObjectView for FieldValue<'_, D> {
|
||||||
pub struct OwnedFields<'a, D: ObjectView>(Vec<FieldValue<'a, D>>);
|
pub struct OwnedFields<'a, D: ObjectView>(Vec<FieldValue<'a, D>>);
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct BorrowedFields<'a, 'map, D: ObjectView> {
|
pub struct BorrowedFields<'a, 'doc, 'map, D: ObjectView> {
|
||||||
document: &'a D,
|
document: &'a D,
|
||||||
field_id_map: &'a RefCell<GlobalFieldsIdsMap<'map>>,
|
field_id_map: &'a RefCell<GlobalFieldsIdsMap<'map>>,
|
||||||
doc_alloc: &'a Bump,
|
doc_alloc: &'doc Bump,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, D: ObjectView> OwnedFields<'a, D> {
|
impl<'a, D: ObjectView> OwnedFields<'a, D> {
|
||||||
|
@ -138,11 +138,11 @@ impl<'a, D: ObjectView> OwnedFields<'a, D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'map, D: ObjectView> BorrowedFields<'a, 'map, D> {
|
impl<'a, 'doc, 'map, D: ObjectView> BorrowedFields<'a, 'doc, 'map, D> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
document: &'a D,
|
document: &'a D,
|
||||||
field_id_map: &'a RefCell<GlobalFieldsIdsMap<'map>>,
|
field_id_map: &'a RefCell<GlobalFieldsIdsMap<'map>>,
|
||||||
doc_alloc: &'a Bump,
|
doc_alloc: &'doc Bump,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { document, field_id_map, doc_alloc }
|
Self { document, field_id_map, doc_alloc }
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ impl<D: ObjectView> ArrayView for OwnedFields<'_, D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: ObjectView> ArrayView for BorrowedFields<'_, '_, D> {
|
impl<D: ObjectView> ArrayView for BorrowedFields<'_, '_, '_, D> {
|
||||||
fn as_value(&self) -> &dyn ValueView {
|
fn as_value(&self) -> &dyn ValueView {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ impl<D: ObjectView> ArrayView for BorrowedFields<'_, '_, D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: ObjectView> ValueView for BorrowedFields<'_, '_, D> {
|
impl<D: ObjectView> ValueView for BorrowedFields<'_, '_, '_, D> {
|
||||||
fn as_debug(&self) -> &dyn std::fmt::Debug {
|
fn as_debug(&self) -> &dyn std::fmt::Debug {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -288,11 +288,11 @@ impl<D: ObjectView> ValueView for OwnedFields<'_, D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ArraySource<'a, 'map, D: ObjectView> {
|
struct ArraySource<'a, 'doc, 'map, D: ObjectView> {
|
||||||
s: &'a BorrowedFields<'a, 'map, D>,
|
s: &'a BorrowedFields<'a, 'doc, 'map, D>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: ObjectView> fmt::Display for ArraySource<'_, '_, D> {
|
impl<D: ObjectView> fmt::Display for ArraySource<'_, '_, '_, D> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "[")?;
|
write!(f, "[")?;
|
||||||
for item in self.s.values() {
|
for item in self.s.values() {
|
||||||
|
@ -303,11 +303,11 @@ impl<D: ObjectView> fmt::Display for ArraySource<'_, '_, D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ArrayRender<'a, 'map, D: ObjectView> {
|
struct ArrayRender<'a, 'doc, 'map, D: ObjectView> {
|
||||||
s: &'a BorrowedFields<'a, 'map, D>,
|
s: &'a BorrowedFields<'a, 'doc, 'map, D>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: ObjectView> fmt::Display for ArrayRender<'_, '_, D> {
|
impl<D: ObjectView> fmt::Display for ArrayRender<'_, '_, '_, D> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
for item in self.s.values() {
|
for item in self.s.values() {
|
||||||
write!(f, "{}", item.render())?;
|
write!(f, "{}", item.render())?;
|
||||||
|
|
|
@ -107,8 +107,8 @@ impl Prompt {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn render_document<
|
pub fn render_document<
|
||||||
'a, // lifetime of the borrow of the document
|
'a, // lifetime of the borrow of the document
|
||||||
'doc: 'a, // lifetime of the allocator, will live for an entire chunk of documents
|
'doc, // lifetime of the allocator, will live for an entire chunk of documents
|
||||||
>(
|
>(
|
||||||
&self,
|
&self,
|
||||||
external_docid: &str,
|
external_docid: &str,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue