From 56f5f100460163ae65b09960c11c13481ed2c5d1 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Fri, 27 May 2022 13:21:41 +0100 Subject: [PATCH] Remove unnecessary std::convert::From implementations --- lib/src/kvs/tx.rs | 6 +++--- lib/src/sql/array.rs | 14 +------------- lib/src/sql/ident.rs | 6 ------ lib/src/sql/idiom.rs | 6 ------ lib/src/sql/part.rs | 8 +------- lib/src/sql/table.rs | 6 ++++++ lib/src/sql/value/every.rs | 10 ++++++++-- lib/src/sql/value/value.rs | 12 ------------ 8 files changed, 19 insertions(+), 49 deletions(-) diff --git a/lib/src/kvs/tx.rs b/lib/src/kvs/tx.rs index 92c79df3..8edede08 100644 --- a/lib/src/kvs/tx.rs +++ b/lib/src/kvs/tx.rs @@ -720,7 +720,7 @@ impl Transaction { .put( key, DefineNamespaceStatement { - name: ns.into(), + name: ns.to_owned().into(), }, ) .await; @@ -733,7 +733,7 @@ impl Transaction { .put( key, DefineDatabaseStatement { - name: db.into(), + name: db.to_owned().into(), }, ) .await; @@ -746,7 +746,7 @@ impl Transaction { .put( key, DefineTableStatement { - name: tb.into(), + name: tb.to_owned().into(), ..DefineTableStatement::default() }, ) diff --git a/lib/src/sql/array.rs b/lib/src/sql/array.rs index ab35c744..5149c78c 100644 --- a/lib/src/sql/array.rs +++ b/lib/src/sql/array.rs @@ -36,19 +36,7 @@ impl From> for Array { impl From> for Array { fn from(v: Vec) -> Self { - Array(v.into_iter().map(|x| x.into()).collect()) - } -} - -impl From> for Array { - fn from(v: Vec) -> Self { - Array(v.into_iter().map(|x| x.into()).collect()) - } -} - -impl From>> for Array { - fn from(v: Vec>) -> Self { - Array(v.into_iter().map(|x| x.into()).collect()) + Array(v.into_iter().map(Value::from).collect()) } } diff --git a/lib/src/sql/ident.rs b/lib/src/sql/ident.rs index 73f78a10..f8df5019 100644 --- a/lib/src/sql/ident.rs +++ b/lib/src/sql/ident.rs @@ -36,12 +36,6 @@ impl From<&str> for Ident { } } -impl From<&String> for Ident { - fn from(i: &String) -> Ident { - Ident(String::from(i)) - } -} - impl Deref for Ident { type Target = String; fn deref(&self) -> &Self::Target { diff --git a/lib/src/sql/idiom.rs b/lib/src/sql/idiom.rs index 5eef0fbd..8c180feb 100644 --- a/lib/src/sql/idiom.rs +++ b/lib/src/sql/idiom.rs @@ -45,12 +45,6 @@ impl Deref for Idiom { } } -impl From for Idiom { - fn from(v: String) -> Self { - Idiom(vec![Part::from(v)]) - } -} - impl From> for Idiom { fn from(v: Vec) -> Self { Idiom(v) diff --git a/lib/src/sql/part.rs b/lib/src/sql/part.rs index 61cc0265..002d0bf9 100644 --- a/lib/src/sql/part.rs +++ b/lib/src/sql/part.rs @@ -67,13 +67,7 @@ impl From for Part { impl From for Part { fn from(v: String) -> Self { - Part::Field(Ident::from(v)) - } -} - -impl From<&String> for Part { - fn from(v: &String) -> Self { - Part::Field(Ident::from(v)) + Part::Field(Ident(v)) } } diff --git a/lib/src/sql/table.rs b/lib/src/sql/table.rs index 42f7e019..ee02a015 100644 --- a/lib/src/sql/table.rs +++ b/lib/src/sql/table.rs @@ -31,6 +31,12 @@ impl From for Table { } } +impl From<&str> for Table { + fn from(v: &str) -> Self { + Table(String::from(v)) + } +} + impl From for Table { fn from(v: Ident) -> Self { Table(v.0) diff --git a/lib/src/sql/value/every.rs b/lib/src/sql/value/every.rs index 208cffb7..20e1f167 100644 --- a/lib/src/sql/value/every.rs +++ b/lib/src/sql/value/every.rs @@ -11,13 +11,19 @@ impl Value { // Current path part is an object Value::Object(v) => v .iter() - .flat_map(|(k, v)| v._every(prev.clone().push(Part::from(k)))) + .flat_map(|(k, v)| { + let p = Part::from(k.to_owned()); + v._every(prev.clone().push(p)) + }) .collect::>(), // Current path part is an array Value::Array(v) => v .iter() .enumerate() - .flat_map(|(i, v)| v._every(prev.clone().push(Part::from(i)))) + .flat_map(|(i, v)| { + let p = Part::from(i.to_owned()); + v._every(prev.clone().push(p)) + }) .collect::>(), // Process everything else _ => vec![prev], diff --git a/lib/src/sql/value/value.rs b/lib/src/sql/value/value.rs index cc872f3a..08f9ae75 100644 --- a/lib/src/sql/value/value.rs +++ b/lib/src/sql/value/value.rs @@ -360,12 +360,6 @@ impl From> for Value { } } -impl From> for Value { - fn from(v: Vec) -> Self { - Value::Array(Array::from(v)) - } -} - impl From> for Value { fn from(v: Vec) -> Self { Value::Array(Array::from(v)) @@ -378,12 +372,6 @@ impl From> for Value { } } -impl From>> for Value { - fn from(v: Vec>) -> Self { - Value::Array(Array::from(v)) - } -} - impl From> for Value { fn from(v: HashMap) -> Self { Value::Object(Object::from(v))