mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 07:41:23 +01:00
enable unnecessary_wraps lint
This commit is contained in:
parent
86218f4771
commit
4e80dc028e
4 changed files with 7 additions and 8 deletions
|
|
@ -85,6 +85,7 @@ uninlined_format_args = "warn"
|
||||||
unnecessary_safety_comment = "warn"
|
unnecessary_safety_comment = "warn"
|
||||||
unnecessary_safety_doc = "warn"
|
unnecessary_safety_doc = "warn"
|
||||||
unnecessary_self_imports = "warn"
|
unnecessary_self_imports = "warn"
|
||||||
|
unnecessary_wraps = "warn"
|
||||||
unneeded_field_pattern = "warn"
|
unneeded_field_pattern = "warn"
|
||||||
unseparated_literal_suffix = "warn"
|
unseparated_literal_suffix = "warn"
|
||||||
verbose_file_reads = "warn"
|
verbose_file_reads = "warn"
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,7 @@ impl KvTree for RocksDbEngineTree<'_> {
|
||||||
let lock = self.write_lock.write().unwrap();
|
let lock = self.write_lock.write().unwrap();
|
||||||
|
|
||||||
let old = self.db.rocks.get_cf_opt(&self.cf(), key, &readoptions)?;
|
let old = self.db.rocks.get_cf_opt(&self.cf(), key, &readoptions)?;
|
||||||
let new = utils::increment(old.as_deref()).unwrap();
|
let new = utils::increment(old.as_deref());
|
||||||
self.db
|
self.db
|
||||||
.rocks
|
.rocks
|
||||||
.put_cf_opt(&self.cf(), key, &new, &writeoptions)?;
|
.put_cf_opt(&self.cf(), key, &new, &writeoptions)?;
|
||||||
|
|
@ -244,7 +244,7 @@ impl KvTree for RocksDbEngineTree<'_> {
|
||||||
|
|
||||||
for key in iter {
|
for key in iter {
|
||||||
let old = self.db.rocks.get_cf_opt(&self.cf(), &key, &readoptions)?;
|
let old = self.db.rocks.get_cf_opt(&self.cf(), &key, &readoptions)?;
|
||||||
let new = utils::increment(old.as_deref()).unwrap();
|
let new = utils::increment(old.as_deref());
|
||||||
self.db
|
self.db
|
||||||
.rocks
|
.rocks
|
||||||
.put_cf_opt(&self.cf(), key, new, &writeoptions)?;
|
.put_cf_opt(&self.cf(), key, new, &writeoptions)?;
|
||||||
|
|
|
||||||
|
|
@ -237,8 +237,7 @@ impl KvTree for SqliteTable {
|
||||||
guard.execute("BEGIN", [])?;
|
guard.execute("BEGIN", [])?;
|
||||||
for key in iter {
|
for key in iter {
|
||||||
let old = self.get_with_guard(&guard, &key)?;
|
let old = self.get_with_guard(&guard, &key)?;
|
||||||
let new = crate::utils::increment(old.as_deref())
|
let new = crate::utils::increment(old.as_deref());
|
||||||
.expect("utils::increment always returns Some");
|
|
||||||
self.insert_with_guard(&guard, &key, &new)?;
|
self.insert_with_guard(&guard, &key, &new)?;
|
||||||
}
|
}
|
||||||
guard.execute("COMMIT", [])?;
|
guard.execute("COMMIT", [])?;
|
||||||
|
|
@ -328,8 +327,7 @@ impl KvTree for SqliteTable {
|
||||||
|
|
||||||
let old = self.get_with_guard(&guard, key)?;
|
let old = self.get_with_guard(&guard, key)?;
|
||||||
|
|
||||||
let new =
|
let new = crate::utils::increment(old.as_deref());
|
||||||
crate::utils::increment(old.as_deref()).expect("utils::increment always returns Some");
|
|
||||||
|
|
||||||
self.insert_with_guard(&guard, key, &new)?;
|
self.insert_with_guard(&guard, key, &new)?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ pub(crate) fn millis_since_unix_epoch() -> u64 {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "rocksdb", feature = "sqlite"))]
|
#[cfg(any(feature = "rocksdb", feature = "sqlite"))]
|
||||||
pub(crate) fn increment(old: Option<&[u8]>) -> Option<Vec<u8>> {
|
pub(crate) fn increment(old: Option<&[u8]>) -> Vec<u8> {
|
||||||
let number = match old.map(TryInto::try_into) {
|
let number = match old.map(TryInto::try_into) {
|
||||||
Some(Ok(bytes)) => {
|
Some(Ok(bytes)) => {
|
||||||
let number = u64::from_be_bytes(bytes);
|
let number = u64::from_be_bytes(bytes);
|
||||||
|
|
@ -30,7 +30,7 @@ pub(crate) fn increment(old: Option<&[u8]>) -> Option<Vec<u8>> {
|
||||||
_ => 1, // Start at one. since 0 should return the first event in the db
|
_ => 1, // Start at one. since 0 should return the first event in the db
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(number.to_be_bytes().to_vec())
|
number.to_be_bytes().to_vec()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn generate_keypair() -> Vec<u8> {
|
pub(crate) fn generate_keypair() -> Vec<u8> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue