From 94ffc054a738b6a11ad7f96e0ec66f662c17238a Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Fri, 1 Apr 2022 23:28:54 +0100 Subject: [PATCH] Fix clippy warnings --- lib/src/dbs/channel.rs | 4 ++-- lib/src/sql/value/mod.rs | 1 + lib/src/sql/value/single.rs | 13 +++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 lib/src/sql/value/single.rs diff --git a/lib/src/dbs/channel.rs b/lib/src/dbs/channel.rs index e9a3034e..b5499898 100644 --- a/lib/src/dbs/channel.rs +++ b/lib/src/dbs/channel.rs @@ -100,7 +100,7 @@ impl Thing { self, ctx: &Runtime, opt: &Options, - stm: &Statement, + _stm: &Statement, txn: &Transaction, chn: &Sender<(Option, Value)>, ) -> Result<(), Error> { @@ -122,7 +122,7 @@ impl Table { self, ctx: &Runtime, opt: &Options, - stm: &Statement, + _stm: &Statement, txn: &Transaction, chn: &Sender<(Option, Value)>, ) -> Result<(), Error> { diff --git a/lib/src/sql/value/mod.rs b/lib/src/sql/value/mod.rs index 744029e7..dffd7f7f 100644 --- a/lib/src/sql/value/mod.rs +++ b/lib/src/sql/value/mod.rs @@ -18,4 +18,5 @@ mod patch; mod pick; mod replace; mod set; +mod single; mod value; diff --git a/lib/src/sql/value/single.rs b/lib/src/sql/value/single.rs new file mode 100644 index 00000000..a3a95dab --- /dev/null +++ b/lib/src/sql/value/single.rs @@ -0,0 +1,13 @@ +use crate::sql::value::Value; + +impl Value { + pub fn single(&self) -> &Self { + match self { + Value::Array(v) => match v.value.first() { + None => &Value::None, + Some(v) => v, + }, + v => v, + } + } +}