Skip to content

Commit 726ec06

Browse files
committed
Remove T on cursors
1 parent 4e8b20f commit 726ec06

File tree

6 files changed

+114
-122
lines changed

6 files changed

+114
-122
lines changed

heed/src/cursor.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ use crate::mdb::error::mdb_result;
55
use crate::mdb::ffi;
66
use crate::*;
77

8-
pub struct RoCursor<'txn, T> {
8+
pub struct RoCursor<'txn> {
99
cursor: *mut ffi::MDB_cursor,
10-
_marker: marker::PhantomData<&'txn T>,
10+
_marker: marker::PhantomData<&'txn ()>,
1111
}
1212

13-
impl<'txn, T> RoCursor<'txn, T> {
13+
impl<'txn> RoCursor<'txn> {
1414
// TODO should I ask for a &mut RoTxn<'_, T>, here?
15-
pub(crate) fn new(txn: &'txn RoTxn<'_, T>, dbi: ffi::MDB_dbi) -> Result<RoCursor<'txn, T>> {
15+
pub(crate) fn new<T>(txn: &'txn RoTxn<'_, T>, dbi: ffi::MDB_dbi) -> Result<RoCursor<'txn>> {
1616
let mut cursor: *mut ffi::MDB_cursor = ptr::null_mut();
1717
let mut txn = txn.txn_ptr();
1818
unsafe { mdb_result(ffi::mdb_cursor_open(txn.as_mut(), dbi, &mut cursor))? }
@@ -237,14 +237,14 @@ impl<'txn, T> RoCursor<'txn, T> {
237237
}
238238
}
239239

240-
impl<T> Drop for RoCursor<'_, T> {
240+
impl Drop for RoCursor<'_> {
241241
fn drop(&mut self) {
242242
unsafe { ffi::mdb_cursor_close(self.cursor) }
243243
}
244244
}
245245

246246
pub struct RwCursor<'txn> {
247-
cursor: RoCursor<'txn, WithoutTls>,
247+
cursor: RoCursor<'txn>,
248248
}
249249

250250
impl<'txn> RwCursor<'txn> {
@@ -404,7 +404,7 @@ impl<'txn> RwCursor<'txn> {
404404
}
405405

406406
impl<'txn> Deref for RwCursor<'txn> {
407-
type Target = RoCursor<'txn, WithoutTls>;
407+
type Target = RoCursor<'txn>;
408408

409409
fn deref(&self) -> &Self::Target {
410410
&self.cursor

heed/src/databases/database.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,13 @@ impl<'e, 'n, T, KC, DC, C> DatabaseOpenOptions<'e, 'n, T, KC, DC, C> {
172172
}
173173
}
174174

175-
impl<T, KC, DC, C> Clone for DatabaseOpenOptions<'_, '_, T, KC, DC, C> {
175+
impl<KC, DC, C> Clone for DatabaseOpenOptions<'_, '_, KC, DC, C> {
176176
fn clone(&self) -> Self {
177177
*self
178178
}
179179
}
180180

181-
impl<T, KC, DC, C> Copy for DatabaseOpenOptions<'_, '_, T, KC, DC, C> {}
181+
impl<KC, DC, C> Copy for DatabaseOpenOptions<'_, '_, KC, DC, C> {}
182182

183183
/// A typed database that accepts only the types it was created with.
184184
///
@@ -433,7 +433,7 @@ impl<KC, DC, C> Database<KC, DC, C> {
433433
&self,
434434
txn: &'txn RoTxn<T>,
435435
key: &'a KC::EItem,
436-
) -> Result<Option<RoIter<'txn, T, KC, DC, MoveOnCurrentKeyDuplicates>>>
436+
) -> Result<Option<RoIter<'txn, KC, DC, MoveOnCurrentKeyDuplicates>>>
437437
where
438438
KC: BytesEncode<'a>,
439439
{
@@ -1026,7 +1026,7 @@ impl<KC, DC, C> Database<KC, DC, C> {
10261026
/// wtxn.commit()?;
10271027
/// # Ok(()) }
10281028
/// ```
1029-
pub fn iter<'txn, T>(&self, txn: &'txn RoTxn<T>) -> Result<RoIter<'txn, T, KC, DC>> {
1029+
pub fn iter<'txn, T>(&self, txn: &'txn RoTxn<T>) -> Result<RoIter<'txn, KC, DC>> {
10301030
assert_eq_env_db_txn!(self, txn);
10311031
RoCursor::new(txn, self.dbi).map(|cursor| RoIter::new(cursor))
10321032
}
@@ -1128,7 +1128,7 @@ impl<KC, DC, C> Database<KC, DC, C> {
11281128
/// wtxn.commit()?;
11291129
/// # Ok(()) }
11301130
/// ```
1131-
pub fn rev_iter<'txn, T>(&self, txn: &'txn RoTxn<T>) -> Result<RoRevIter<'txn, T, KC, DC>> {
1131+
pub fn rev_iter<'txn, T>(&self, txn: &'txn RoTxn<T>) -> Result<RoRevIter<'txn, KC, DC>> {
11321132
assert_eq_env_db_txn!(self, txn);
11331133

11341134
RoCursor::new(txn, self.dbi).map(|cursor| RoRevIter::new(cursor))
@@ -1239,7 +1239,7 @@ impl<KC, DC, C> Database<KC, DC, C> {
12391239
&self,
12401240
txn: &'txn RoTxn<T>,
12411241
range: &'a R,
1242-
) -> Result<RoRange<'txn, T, KC, DC, C>>
1242+
) -> Result<RoRange<'txn, KC, DC, C>>
12431243
where
12441244
KC: BytesEncode<'a>,
12451245
R: RangeBounds<KC::EItem>,
@@ -1412,7 +1412,7 @@ impl<KC, DC, C> Database<KC, DC, C> {
14121412
&self,
14131413
txn: &'txn RoTxn<T>,
14141414
range: &'a R,
1415-
) -> Result<RoRevRange<'txn, T, KC, DC, C>>
1415+
) -> Result<RoRevRange<'txn, KC, DC, C>>
14161416
where
14171417
KC: BytesEncode<'a>,
14181418
R: RangeBounds<KC::EItem>,
@@ -1587,7 +1587,7 @@ impl<KC, DC, C> Database<KC, DC, C> {
15871587
&self,
15881588
txn: &'txn RoTxn<T>,
15891589
prefix: &'a KC::EItem,
1590-
) -> Result<RoPrefix<'txn, T, KC, DC, C>>
1590+
) -> Result<RoPrefix<'txn, KC, DC, C>>
15911591
where
15921592
KC: BytesEncode<'a>,
15931593
C: LexicographicComparator,
@@ -1720,7 +1720,7 @@ impl<KC, DC, C> Database<KC, DC, C> {
17201720
&self,
17211721
txn: &'txn RoTxn<'_, T>,
17221722
prefix: &'a KC::EItem,
1723-
) -> Result<RoRevPrefix<'txn, T, KC, DC, C>>
1723+
) -> Result<RoRevPrefix<'txn, KC, DC, C>>
17241724
where
17251725
KC: BytesEncode<'a>,
17261726
C: LexicographicComparator,

heed/src/databases/encrypted_database.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ use crate::*;
5353
/// # Ok(()) }
5454
/// ```
5555
#[derive(Debug)]
56-
pub struct EncryptedDatabaseOpenOptions<'e, 'n, T, KC, DC, C = DefaultComparator> {
57-
inner: DatabaseOpenOptions<'e, 'n, T, KC, DC, C>,
56+
pub struct EncryptedDatabaseOpenOptions<'e, 'n, KC, DC, C = DefaultComparator> {
57+
inner: DatabaseOpenOptions<'e, 'n, KC, DC, C>,
5858
}
5959

6060
impl<'e, T> EncryptedDatabaseOpenOptions<'e, 'static, T, Unspecified, Unspecified> {
@@ -64,7 +64,7 @@ impl<'e, T> EncryptedDatabaseOpenOptions<'e, 'static, T, Unspecified, Unspecifie
6464
}
6565
}
6666

67-
impl<'e, 'n, T, KC, DC, C> EncryptedDatabaseOpenOptions<'e, 'n, T, KC, DC, C> {
67+
impl<'e, 'n, KC, DC, C> EncryptedDatabaseOpenOptions<'e, 'n, KC, DC, C> {
6868
/// Change the type of the database.
6969
///
7070
/// The default types are [`Unspecified`] and require a call to [`Database::remap_types`]
@@ -75,7 +75,7 @@ impl<'e, 'n, T, KC, DC, C> EncryptedDatabaseOpenOptions<'e, 'n, T, KC, DC, C> {
7575
/// Change the customized key compare function of the database.
7676
///
7777
/// By default no customized compare function will be set when opening a database.
78-
pub fn key_comparator<NC>(self) -> EncryptedDatabaseOpenOptions<'e, 'n, T, KC, DC, NC> {
78+
pub fn key_comparator<NC>(self) -> EncryptedDatabaseOpenOptions<'e, 'n, KC, DC, NC> {
7979
EncryptedDatabaseOpenOptions { inner: self.inner.key_comparator() }
8080
}
8181

@@ -139,13 +139,13 @@ impl<'e, 'n, T, KC, DC, C> EncryptedDatabaseOpenOptions<'e, 'n, T, KC, DC, C> {
139139
}
140140
}
141141

142-
impl<T, KC, DC, C> Clone for EncryptedDatabaseOpenOptions<'_, '_, T, KC, DC, C> {
142+
impl<KC, DC, C> Clone for EncryptedDatabaseOpenOptions<'_, '_, KC, DC, C> {
143143
fn clone(&self) -> Self {
144144
*self
145145
}
146146
}
147147

148-
impl<T, KC, DC, C> Copy for EncryptedDatabaseOpenOptions<'_, '_, T, KC, DC, C> {}
148+
impl<KC, DC, C> Copy for EncryptedDatabaseOpenOptions<'_, '_, KC, DC, C> {}
149149

150150
/// A typed database that accepts only the types it was created with.
151151
///
@@ -374,7 +374,7 @@ impl<KC, DC, C> EncryptedDatabase<KC, DC, C> {
374374
&self,
375375
txn: &'txn mut RoTxn<T>,
376376
key: &'a KC::EItem,
377-
) -> Result<Option<RoIter<'txn, T, KC, DC, MoveOnCurrentKeyDuplicates>>>
377+
) -> Result<Option<RoIter<'txn, KC, DC, MoveOnCurrentKeyDuplicates>>>
378378
where
379379
KC: BytesEncode<'a>,
380380
{
@@ -862,7 +862,7 @@ impl<KC, DC, C> EncryptedDatabase<KC, DC, C> {
862862
/// wtxn.commit()?;
863863
/// # Ok(()) }
864864
/// ```
865-
pub fn iter<'txn, T>(&self, txn: &'txn mut RoTxn<T>) -> Result<RoIter<'txn, T, KC, DC>> {
865+
pub fn iter<'txn, T>(&self, txn: &'txn mut RoTxn<T>) -> Result<RoIter<'txn, KC, DC>> {
866866
self.inner.iter(txn)
867867
}
868868

@@ -961,7 +961,7 @@ impl<KC, DC, C> EncryptedDatabase<KC, DC, C> {
961961
/// wtxn.commit()?;
962962
/// # Ok(()) }
963963
/// ```
964-
pub fn rev_iter<'txn, T>(&self, txn: &'txn mut RoTxn<T>) -> Result<RoRevIter<'txn, T, KC, DC>> {
964+
pub fn rev_iter<'txn, T>(&self, txn: &'txn mut RoTxn<T>) -> Result<RoRevIter<'txn, KC, DC>> {
965965
self.inner.rev_iter(txn)
966966
}
967967

@@ -1068,7 +1068,7 @@ impl<KC, DC, C> EncryptedDatabase<KC, DC, C> {
10681068
&self,
10691069
txn: &'txn mut RoTxn<T>,
10701070
range: &'a R,
1071-
) -> Result<RoRange<'txn, T, KC, DC, C>>
1071+
) -> Result<RoRange<'txn, KC, DC, C>>
10721072
where
10731073
KC: BytesEncode<'a>,
10741074
R: RangeBounds<KC::EItem>,
@@ -1191,7 +1191,7 @@ impl<KC, DC, C> EncryptedDatabase<KC, DC, C> {
11911191
&self,
11921192
txn: &'txn mut RoTxn<T>,
11931193
range: &'a R,
1194-
) -> Result<RoRevRange<'txn, T, KC, DC, C>>
1194+
) -> Result<RoRevRange<'txn, KC, DC, C>>
11951195
where
11961196
KC: BytesEncode<'a>,
11971197
R: RangeBounds<KC::EItem>,
@@ -1315,7 +1315,7 @@ impl<KC, DC, C> EncryptedDatabase<KC, DC, C> {
13151315
&self,
13161316
txn: &'txn mut RoTxn<T>,
13171317
prefix: &'a KC::EItem,
1318-
) -> Result<RoPrefix<'txn, T, KC, DC, C>>
1318+
) -> Result<RoPrefix<'txn, KC, DC, C>>
13191319
where
13201320
KC: BytesEncode<'a>,
13211321
C: LexicographicComparator,
@@ -1440,7 +1440,7 @@ impl<KC, DC, C> EncryptedDatabase<KC, DC, C> {
14401440
&self,
14411441
txn: &'txn mut RoTxn<T>,
14421442
prefix: &'a KC::EItem,
1443-
) -> Result<RoRevPrefix<'txn, T, KC, DC, C>>
1443+
) -> Result<RoRevPrefix<'txn, KC, DC, C>>
14441444
where
14451445
KC: BytesEncode<'a>,
14461446
C: LexicographicComparator,

0 commit comments

Comments
 (0)