Skip to content

Commit 28c4b56

Browse files
committed
Remove the Generic T type from the transactions
1 parent 28a05ab commit 28c4b56

File tree

6 files changed

+298
-348
lines changed

6 files changed

+298
-348
lines changed

heed/examples/all-types-poly.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ fn main() -> Result<(), Box<dyn Error>> {
2525
let db = env.create_poly_database(Some("kikou"))?;
2626

2727
let mut wtxn = env.write_txn()?;
28-
db.put::<_, OwnedType<[i32; 2]>, Str>(&mut wtxn, &[2, 3], "what's up?")?;
29-
let ret = db.get::<_, OwnedType<[i32; 2]>, Str>(&wtxn, &[2, 3])?;
28+
db.put::<OwnedType<[i32; 2]>, Str>(&mut wtxn, &[2, 3], "what's up?")?;
29+
let ret = db.get::<OwnedType<[i32; 2]>, Str>(&wtxn, &[2, 3])?;
3030

3131
println!("{:?}", ret);
3232
wtxn.commit()?;
@@ -35,8 +35,8 @@ fn main() -> Result<(), Box<dyn Error>> {
3535
let db = env.create_poly_database(Some("kiki"))?;
3636

3737
let mut wtxn = env.write_txn()?;
38-
db.put::<_, Str, ByteSlice>(&mut wtxn, "hello", &[2, 3][..])?;
39-
let ret = db.get::<_, Str, ByteSlice>(&wtxn, "hello")?;
38+
db.put::<Str, ByteSlice>(&mut wtxn, "hello", &[2, 3][..])?;
39+
let ret = db.get::<Str, ByteSlice>(&wtxn, "hello")?;
4040

4141
println!("{:?}", ret);
4242
wtxn.commit()?;
@@ -52,15 +52,15 @@ fn main() -> Result<(), Box<dyn Error>> {
5252
let mut wtxn = env.write_txn()?;
5353

5454
let hello = Hello { string: "hi" };
55-
db.put::<_, Str, SerdeBincode<Hello>>(&mut wtxn, "hello", &hello)?;
55+
db.put::<Str, SerdeBincode<Hello>>(&mut wtxn, "hello", &hello)?;
5656

57-
let ret = db.get::<_, Str, SerdeBincode<Hello>>(&wtxn, "hello")?;
57+
let ret = db.get::<Str, SerdeBincode<Hello>>(&wtxn, "hello")?;
5858
println!("serde-bincode:\t{:?}", ret);
5959

6060
let hello = Hello { string: "hi" };
61-
db.put::<_, Str, SerdeJson<Hello>>(&mut wtxn, "hello", &hello)?;
61+
db.put::<Str, SerdeJson<Hello>>(&mut wtxn, "hello", &hello)?;
6262

63-
let ret = db.get::<_, Str, SerdeJson<Hello>>(&wtxn, "hello")?;
63+
let ret = db.get::<Str, SerdeJson<Hello>>(&wtxn, "hello")?;
6464
println!("serde-json:\t{:?}", ret);
6565

6666
wtxn.commit()?;
@@ -76,9 +76,9 @@ fn main() -> Result<(), Box<dyn Error>> {
7676
let mut wtxn = env.write_txn()?;
7777

7878
let zerobytes = ZeroBytes { bytes: [24; 12] };
79-
db.put::<_, Str, UnalignedType<ZeroBytes>>(&mut wtxn, "zero", &zerobytes)?;
79+
db.put::<Str, UnalignedType<ZeroBytes>>(&mut wtxn, "zero", &zerobytes)?;
8080

81-
let ret = db.get::<_, Str, UnalignedType<ZeroBytes>>(&wtxn, "zero")?;
81+
let ret = db.get::<Str, UnalignedType<ZeroBytes>>(&wtxn, "zero")?;
8282

8383
println!("{:?}", ret);
8484
wtxn.commit()?;
@@ -87,12 +87,12 @@ fn main() -> Result<(), Box<dyn Error>> {
8787
let db = env.create_poly_database(Some("ignored-data"))?;
8888

8989
let mut wtxn = env.write_txn()?;
90-
db.put::<_, Str, Unit>(&mut wtxn, "hello", &())?;
91-
let ret = db.get::<_, Str, Unit>(&wtxn, "hello")?;
90+
db.put::<Str, Unit>(&mut wtxn, "hello", &())?;
91+
let ret = db.get::<Str, Unit>(&wtxn, "hello")?;
9292

9393
println!("{:?}", ret);
9494

95-
let ret = db.get::<_, Str, Unit>(&wtxn, "non-existant")?;
95+
let ret = db.get::<Str, Unit>(&wtxn, "non-existant")?;
9696

9797
println!("{:?}", ret);
9898
wtxn.commit()?;
@@ -117,27 +117,27 @@ fn main() -> Result<(), Box<dyn Error>> {
117117
let db = env.create_poly_database(Some("big-endian-iter"))?;
118118

119119
let mut wtxn = env.write_txn()?;
120-
db.put::<_, OwnedType<BEI64>, Unit>(&mut wtxn, &BEI64::new(0), &())?;
121-
db.put::<_, OwnedType<BEI64>, Unit>(&mut wtxn, &BEI64::new(68), &())?;
122-
db.put::<_, OwnedType<BEI64>, Unit>(&mut wtxn, &BEI64::new(35), &())?;
123-
db.put::<_, OwnedType<BEI64>, Unit>(&mut wtxn, &BEI64::new(42), &())?;
120+
db.put::<OwnedType<BEI64>, Unit>(&mut wtxn, &BEI64::new(0), &())?;
121+
db.put::<OwnedType<BEI64>, Unit>(&mut wtxn, &BEI64::new(68), &())?;
122+
db.put::<OwnedType<BEI64>, Unit>(&mut wtxn, &BEI64::new(35), &())?;
123+
db.put::<OwnedType<BEI64>, Unit>(&mut wtxn, &BEI64::new(42), &())?;
124124

125-
let rets: Result<Vec<(BEI64, _)>, _> = db.iter::<_, OwnedType<BEI64>, Unit>(&wtxn)?.collect();
125+
let rets: Result<Vec<(BEI64, _)>, _> = db.iter::<OwnedType<BEI64>, Unit>(&wtxn)?.collect();
126126

127127
println!("{:?}", rets);
128128

129129
// or iterate over ranges too!!!
130130
let range = BEI64::new(35)..=BEI64::new(42);
131131
let rets: Result<Vec<(BEI64, _)>, _> =
132-
db.range::<_, OwnedType<BEI64>, Unit, _>(&wtxn, &range)?.collect();
132+
db.range::<OwnedType<BEI64>, Unit, _>(&wtxn, &range)?.collect();
133133

134134
println!("{:?}", rets);
135135

136136
// delete a range of key
137137
let range = BEI64::new(35)..=BEI64::new(42);
138-
let deleted: usize = db.delete_range::<_, OwnedType<BEI64>, _>(&mut wtxn, &range)?;
138+
let deleted: usize = db.delete_range::<OwnedType<BEI64>, _>(&mut wtxn, &range)?;
139139

140-
let rets: Result<Vec<(BEI64, _)>, _> = db.iter::<_, OwnedType<BEI64>, Unit>(&wtxn)?.collect();
140+
let rets: Result<Vec<(BEI64, _)>, _> = db.iter::<OwnedType<BEI64>, Unit>(&wtxn)?.collect();
141141

142142
println!("deleted: {:?}, {:?}", deleted, rets);
143143
wtxn.commit()?;

heed/src/cursor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub struct RoCursor<'txn> {
1111
}
1212

1313
impl<'txn> RoCursor<'txn> {
14-
pub(crate) fn new<T>(txn: &'txn RoTxn<T>, dbi: ffi::MDB_dbi) -> Result<RoCursor<'txn>> {
14+
pub(crate) fn new(txn: &'txn RoTxn, dbi: ffi::MDB_dbi) -> Result<RoCursor<'txn>> {
1515
let mut cursor: *mut ffi::MDB_cursor = ptr::null_mut();
1616

1717
unsafe { mdb_result(ffi::mdb_cursor_open(txn.txn, dbi, &mut cursor))? }
@@ -184,7 +184,7 @@ pub struct RwCursor<'txn> {
184184
}
185185

186186
impl<'txn> RwCursor<'txn> {
187-
pub(crate) fn new<T>(txn: &'txn RwTxn<T>, dbi: ffi::MDB_dbi) -> Result<RwCursor<'txn>> {
187+
pub(crate) fn new(txn: &'txn RwTxn, dbi: ffi::MDB_dbi) -> Result<RwCursor<'txn>> {
188188
Ok(RwCursor { cursor: RoCursor::new(txn, dbi)? })
189189
}
190190

0 commit comments

Comments
 (0)