Simplify v.into() value conversion statements

This commit is contained in:
Tobie Morgan Hitchcock 2022-07-16 23:18:24 +01:00
parent 38f560c213
commit c9d9b041f7
5 changed files with 11 additions and 11 deletions

View file

@ -154,7 +154,7 @@ impl Transaction {
return Err(Error::TxReadonly); return Err(Error::TxReadonly);
} }
// Set the key // Set the key
self.tx.putc(key.into(), val.into(), chk.map(|v| v.into()))?; self.tx.putc(key.into(), val.into(), chk.map(Into::into))?;
// Return result // Return result
Ok(()) Ok(())
} }
@ -191,7 +191,7 @@ impl Transaction {
return Err(Error::TxReadonly); return Err(Error::TxReadonly);
} }
// Remove the key // Remove the key
self.tx.delc(key.into(), chk.map(|v| v.into()))?; self.tx.delc(key.into(), chk.map(Into::into))?;
// Return result // Return result
Ok(()) Ok(())
} }

View file

@ -157,7 +157,7 @@ impl Transaction {
return Err(Error::TxReadonly); return Err(Error::TxReadonly);
} }
// Set the key // Set the key
self.tx.putc(key.into(), val.into(), chk.map(|v| v.into())).await?; self.tx.putc(key.into(), val.into(), chk.map(Into::into)).await?;
// Return result // Return result
Ok(()) Ok(())
} }
@ -194,7 +194,7 @@ impl Transaction {
return Err(Error::TxReadonly); return Err(Error::TxReadonly);
} }
// Remove the key // Remove the key
let res = self.tx.delc(key.into(), chk.map(|v| v.into())).await?; let res = self.tx.delc(key.into(), chk.map(Into::into)).await?;
// Return result // Return result
Ok(res) Ok(res)
} }

View file

@ -154,7 +154,7 @@ impl Transaction {
return Err(Error::TxReadonly); return Err(Error::TxReadonly);
} }
// Set the key // Set the key
self.tx.putc(key.into(), val.into(), chk.map(|v| v.into()))?; self.tx.putc(key.into(), val.into(), chk.map(Into::into))?;
// Return result // Return result
Ok(()) Ok(())
} }
@ -191,7 +191,7 @@ impl Transaction {
return Err(Error::TxReadonly); return Err(Error::TxReadonly);
} }
// Remove the key // Remove the key
self.tx.delc(key.into(), chk.map(|v| v.into()))?; self.tx.delc(key.into(), chk.map(Into::into))?;
// Return result // Return result
Ok(()) Ok(())
} }

View file

@ -171,7 +171,7 @@ impl Transaction {
// Get the val // Get the val
let val = val.into(); let val = val.into();
// Get the check // Get the check
let chk = chk.map(|v| v.into()); let chk = chk.map(Into::into);
// Delete the key // Delete the key
match (self.tx.get(key.clone()).await?, chk) { match (self.tx.get(key.clone()).await?, chk) {
(Some(v), Some(w)) if v == w => self.tx.put(key, val).await?, (Some(v), Some(w)) if v == w => self.tx.put(key, val).await?,
@ -216,7 +216,7 @@ impl Transaction {
// Get the key // Get the key
let key = key.into(); let key = key.into();
// Get the check // Get the check
let chk = chk.map(|v| v.into()); let chk = chk.map(Into::into);
// Delete the key // Delete the key
match (self.tx.get(key.clone()).await?, chk) { match (self.tx.get(key.clone()).await?, chk) {
(Some(v), Some(w)) if v == w => self.tx.delete(key).await?, (Some(v), Some(w)) if v == w => self.tx.delete(key).await?,

View file

@ -44,11 +44,11 @@ impl Value {
Part::All => { Part::All => {
let path = path.next(); let path = path.next();
let futs = v.iter().map(|v| v.get(ctx, opt, txn, path)); let futs = v.iter().map(|v| v.get(ctx, opt, txn, path));
try_join_all(futs).await.map(|v| v.into()) try_join_all(futs).await.map(Into::into)
} }
Part::Any => { Part::Any => {
let futs = v.iter().map(|v| v.get(ctx, opt, txn, path)); let futs = v.iter().map(|v| v.get(ctx, opt, txn, path));
try_join_all(futs).await.map(|v| v.into()) try_join_all(futs).await.map(Into::into)
} }
Part::First => match v.first() { Part::First => match v.first() {
Some(v) => v.get(ctx, opt, txn, path.next()).await, Some(v) => v.get(ctx, opt, txn, path.next()).await,
@ -74,7 +74,7 @@ impl Value {
} }
_ => { _ => {
let futs = v.iter().map(|v| v.get(ctx, opt, txn, path)); let futs = v.iter().map(|v| v.get(ctx, opt, txn, path));
try_join_all(futs).await.map(|v| v.into()) try_join_all(futs).await.map(Into::into)
} }
}, },
// Current path part is a thing // Current path part is a thing