Skip to content

Commit 8cc9bd6

Browse files
committed
cleanup: lifetime elision warnings
1 parent 013c971 commit 8cc9bd6

File tree

10 files changed

+45
-40
lines changed

10 files changed

+45
-40
lines changed

src/annotation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ impl Annotation {
572572

573573
/// Iterate over the annotation data, returns tuples of internal IDs for (annotationset,annotationdata)
574574
/// For a higher-level method, use [`ResultItem<Annotation>::data()`] instead.
575-
pub fn data(&self) -> Iter<(AnnotationDataSetHandle, AnnotationDataHandle)> {
575+
pub fn data<'a>(&'a self) -> Iter<'a, (AnnotationDataSetHandle, AnnotationDataHandle)> {
576576
self.data.iter()
577577
}
578578

src/annotationdata.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ impl<'a> AnnotationDataBuilder<'a> {
289289
self
290290
}
291291

292-
pub fn id(&self) -> &BuildItem<AnnotationData> {
292+
pub fn id(&self) -> &BuildItem<'_, AnnotationData> {
293293
&self.id
294294
}
295295

@@ -298,7 +298,7 @@ impl<'a> AnnotationDataBuilder<'a> {
298298
self
299299
}
300300

301-
pub fn dataset(&self) -> &BuildItem<AnnotationDataSet> {
301+
pub fn dataset(&self) -> &BuildItem<'_, AnnotationDataSet> {
302302
&self.dataset
303303
}
304304

@@ -307,7 +307,7 @@ impl<'a> AnnotationDataBuilder<'a> {
307307
self
308308
}
309309

310-
pub fn key(&self) -> &BuildItem<DataKey> {
310+
pub fn key(&self) -> &BuildItem<'_, DataKey> {
311311
&self.key
312312
}
313313

src/annotationdataset.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,12 +652,12 @@ impl AnnotationDataSet {
652652
}
653653

654654
///Returns an iterator over all the data ([`AnnotationData`]) in this set, the iterator returns references to [`AnnotationData`].
655-
pub fn data(&self) -> StoreIter<AnnotationData> {
655+
pub fn data<'a>(&'a self) -> StoreIter<'a, AnnotationData> {
656656
<Self as StoreFor<AnnotationData>>::iter(self)
657657
}
658658

659659
/// Returns an iterator over all the keys ([`DataKey`]) in this set, the iterator in returns references to [`DataKey`]
660-
pub fn keys(&self) -> StoreIter<DataKey> {
660+
pub fn keys<'a>(&'a self) -> StoreIter<'a, DataKey> {
661661
<Self as StoreFor<DataKey>>::iter(self)
662662
}
663663

src/api/annotationstore.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,28 @@ impl AnnotationStore {
3131
///
3232
/// The item is returned as a fat pointer [`ResultItem<TextResource>`]) in an Option.
3333
/// Returns `None` if it does not exist.
34-
pub fn resource(
35-
&self,
34+
pub fn resource<'a>(
35+
&'a self,
3636
request: impl Request<TextResource>,
37-
) -> Option<ResultItem<TextResource>> {
37+
) -> Option<ResultItem<'a, TextResource>> {
3838
self.get(request).map(|x| x.as_resultitem(self, self)).ok()
3939
}
4040

4141
/// Requests a specific [`AnnotationDataSet`] from the store to be returned by reference.
4242
/// The `request` parameter encapsulates some kind of identifier, it can be a `&str`, [`String`] or [`AnnotationDataSetHandle`].
43-
pub fn dataset(
44-
&self,
43+
pub fn dataset<'a>(
44+
&'a self,
4545
request: impl Request<AnnotationDataSet>,
46-
) -> Option<ResultItem<AnnotationDataSet>> {
46+
) -> Option<ResultItem<'a, AnnotationDataSet>> {
4747
self.get(request).map(|x| x.as_resultitem(self, self)).ok()
4848
}
4949

5050
/// Requests a specific [`DataKey`] (pertaining to an [`AnnotationDataSet`]) to be returned by reference.
51-
pub fn key(
52-
&self,
51+
pub fn key<'a>(
52+
&'a self,
5353
set: impl Request<AnnotationDataSet>,
5454
key: impl Request<DataKey>,
55-
) -> Option<ResultItem<DataKey>> {
55+
) -> Option<ResultItem<'a, DataKey>> {
5656
if let Some(dataset) = self.dataset(set) {
5757
dataset.key(key)
5858
} else {
@@ -61,11 +61,11 @@ impl AnnotationStore {
6161
}
6262

6363
/// Requests a specific [`AnnotationData`] (pertaining to an [`AnnotationDataSet`]) to be returned by reference.
64-
pub fn annotationdata(
65-
&self,
64+
pub fn annotationdata<'a>(
65+
&'a self,
6666
set: impl Request<AnnotationDataSet>,
6767
data: impl Request<AnnotationData>,
68-
) -> Option<ResultItem<AnnotationData>> {
68+
) -> Option<ResultItem<'a, AnnotationData>> {
6969
if let Some(dataset) = self.dataset(set) {
7070
dataset.annotationdata(data)
7171
} else {
@@ -74,11 +74,11 @@ impl AnnotationStore {
7474
}
7575

7676
/// Requests a specific [`TextSelection`] by handle (pertaining to an [`AnnotationDataSet`]) to be returned by reference.
77-
pub fn textselection(
78-
&self,
77+
pub fn textselection<'a>(
78+
&'a self,
7979
resource: impl Request<TextResource>,
8080
handle: TextSelectionHandle,
81-
) -> Option<ResultTextSelection> {
81+
) -> Option<ResultTextSelection<'a>> {
8282
if let Some(resource) = self.resource(resource) {
8383
resource.textselection_by_handle(handle).ok()
8484
} else {
@@ -92,16 +92,19 @@ impl AnnotationStore {
9292
/// The item is returned as a fat pointer [`ResultItem<Annotation>`]),
9393
/// which exposes the high-level API, in an Option.
9494
/// Returns `None` if it does not exist.
95-
pub fn annotation(&self, request: impl Request<Annotation>) -> Option<ResultItem<Annotation>> {
95+
pub fn annotation<'a>(
96+
&'a self,
97+
request: impl Request<Annotation>,
98+
) -> Option<ResultItem<'a, Annotation>> {
9699
self.get(request).map(|x| x.as_resultitem(self, self)).ok()
97100
}
98101

99102
/// Requests a specific [`AnnotationSubStore`] from the store to be returned by reference.
100103
/// The `request` parameter encapsulates some kind of identifier, it can be a `&str`, [`String`] or [`AnnotationSubStoreHandle`].
101-
pub fn substore(
102-
&self,
104+
pub fn substore<'a>(
105+
&'a self,
103106
request: impl Request<AnnotationSubStore>,
104-
) -> Option<ResultItem<AnnotationSubStore>> {
107+
) -> Option<ResultItem<'a, AnnotationSubStore>> {
105108
self.get(request).map(|x| x.as_resultitem(self, self)).ok()
106109
}
107110

src/api/query.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,12 +1115,12 @@ impl<'a> Query<'a> {
11151115
}
11161116

11171117
/// Iterates over all constraints in the Query
1118-
pub fn constraints(&self) -> std::slice::Iter<Constraint<'a>> {
1118+
pub fn constraints(&'a self) -> std::slice::Iter<'a, Constraint<'a>> {
11191119
self.constraints.iter()
11201120
}
11211121

11221122
/// Returns all attributes for this query
1123-
pub fn attributes(&self) -> std::slice::Iter<&'a str> {
1123+
pub fn attributes(&'a self) -> std::slice::Iter<'a, &'a str> {
11241124
self.attributes.iter()
11251125
}
11261126

@@ -1135,12 +1135,12 @@ impl<'a> Query<'a> {
11351135

11361136
/// Iterates over all constraints in the Query
11371137
/// Alias for `constraints()`,
1138-
pub fn iter(&self) -> std::slice::Iter<Constraint<'a>> {
1138+
pub fn iter(&'a self) -> std::slice::Iter<'a, Constraint<'a>> {
11391139
self.constraints.iter()
11401140
}
11411141

11421142
/// Iterates over all assignments in the Query
1143-
pub fn assignments(&self) -> std::slice::Iter<Assignment<'a>> {
1143+
pub fn assignments(&'a self) -> std::slice::Iter<'a, Assignment<'a>> {
11441144
self.assignments.iter()
11451145
}
11461146

src/api/textselection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ impl<'store> ResultTextSelection<'store> {
310310
}
311311

312312
/// Iterator covering the full text of text selection as a sequence of minimum-length non-overlapping TextSelections, in textual order
313-
pub fn segmentation(&self) -> SegmentationIter {
313+
pub fn segmentation<'a>(&'a self) -> SegmentationIter<'a> {
314314
self.resource()
315315
.segmentation_in_range(self.begin(), self.end())
316316
}

src/api/translate.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
use std::collections::VecDeque;
21

3-
use crate::{api::*, Cursor, ResultTextSelection};
2+
use crate::{api::*, ResultTextSelection};
43
use crate::datavalue::DataValue;
5-
use crate::selector::{Offset, OffsetMode, SelectorBuilder};
4+
use crate::selector::{Offset, SelectorBuilder};
65
use crate::text::Text;
76
use crate::textselection::{ResultTextSelectionSet, TestTextSelection};
87
use crate::AnnotationBuilder;

src/resources.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ impl TextResource {
730730
}
731731

732732
/// Returns a low-level iterator over the position index
733-
pub fn positionindex_iter(&self) -> btree_map::Iter<usize, PositionIndexItem> {
733+
pub fn positionindex_iter<'a>(&'a self) -> btree_map::Iter<'a, usize, PositionIndexItem> {
734734
self.positionindex.0.iter()
735735
}
736736

src/store.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ pub trait StoreFor<T: Storable>: Configurable + private::StoreCallbacks<T> {
905905
/// Iterate over all items in the store
906906
/// This is a low-level API method, use dedicated high-level iterators like `annotations()`, `resources()` instead.
907907
#[inline]
908-
fn iter(&self) -> StoreIter<T>
908+
fn iter<'a>(&'a self) -> StoreIter<'a, T>
909909
where
910910
T: Storable<StoreType = Self>,
911911
{
@@ -918,7 +918,7 @@ pub trait StoreFor<T: Storable>: Configurable + private::StoreCallbacks<T> {
918918

919919
/// Iterate over the store, mutably
920920
/// This is a low-level API method.
921-
fn iter_mut(&mut self) -> StoreIterMut<T> {
921+
fn iter_mut<'a>(&'a mut self) -> StoreIterMut<'a, T> {
922922
let len = self.store().len();
923923
StoreIterMut {
924924
iter: self.store_mut().iter_mut(),
@@ -981,7 +981,10 @@ pub(crate) mod private {
981981
pub(crate) trait WrappableStore<T: Storable>: StoreFor<T> {
982982
/// Wraps the entire store along with a reference to self
983983
/// Low-level method that you won't need
984-
fn wrap_store(&self, substore: Option<AnnotationSubStoreHandle>) -> WrappedStore<T, Self>
984+
fn wrap_store<'a>(
985+
&'a self,
986+
substore: Option<AnnotationSubStoreHandle>,
987+
) -> WrappedStore<'a, T, Self>
985988
where
986989
Self: Sized,
987990
{

src/textselection.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,10 +506,10 @@ impl Default for PositionIndex {
506506

507507
impl PositionIndex {
508508
//Returns an iterator over all positions in in index, in sorted order
509-
pub fn keys(&self) -> btree_map::Keys<usize, PositionIndexItem> {
509+
pub fn keys<'a>(&'a self) -> btree_map::Keys<'a, usize, PositionIndexItem> {
510510
self.0.keys()
511511
}
512-
pub fn iter(&self) -> btree_map::Iter<usize, PositionIndexItem> {
512+
pub fn iter<'a>(&'a self) -> btree_map::Iter<'a, usize, PositionIndexItem> {
513513
self.0.iter()
514514
}
515515
}
@@ -1220,7 +1220,7 @@ impl TextSelectionSet {
12201220
}
12211221
}
12221222

1223-
pub fn as_resultset(self, store: &AnnotationStore) -> ResultTextSelectionSet {
1223+
pub fn as_resultset<'a>(self, store: &'a AnnotationStore) -> ResultTextSelectionSet<'a> {
12241224
ResultTextSelectionSet {
12251225
tset: self,
12261226
rootstore: store,

0 commit comments

Comments
 (0)