From 06cfd395e2176cdd57d780c003e1aefd59dc8d1d Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 9 Feb 2024 00:18:54 +0900 Subject: [PATCH] Fix dead_code warning ``` error: function `allow_null` is never used --> src/metadata.rs:112:4 | 112 | fn allow_null(value: Value, f: impl FnOnce(Value) -> Option) -> Option> { | ^^^^^^^^^^ | = note: `-D dead-code` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(dead_code)]` error: function `into_object` is never used --> src/metadata.rs:134:4 | 134 | fn into_object(value: Value) -> Option { | ^^^^^^^^^^^ error: methods `remove_object` and `remove_nullable` are never used --> src/metadata.rs:145:8 | 142 | trait ObjectExt { | --------- methods in this trait ... 145 | fn remove_object(&mut self, key: &'static str) -> ParseResult; | ^^^^^^^^^^^^^ 146 | fn remove_nullable( | ^^^^^^^^^^^^^^^ ``` --- src/metadata.rs | 62 ++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/metadata.rs b/src/metadata.rs index 162c89af..ee551ca9 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -108,14 +108,14 @@ impl Target { } } -#[allow(clippy::option_option)] -fn allow_null(value: Value, f: impl FnOnce(Value) -> Option) -> Option> { - if value.is_null() { - Some(None) - } else { - f(value).map(Some) - } -} +// #[allow(clippy::option_option)] +// fn allow_null(value: Value, f: impl FnOnce(Value) -> Option) -> Option> { +// if value.is_null() { +// Some(None) +// } else { +// f(value).map(Some) +// } +// } fn into_string>(value: Value) -> Option { if let Value::String(string) = value { @@ -131,23 +131,23 @@ fn into_array(value: Value) -> Option> { None } } -fn into_object(value: Value) -> Option { - if let Value::Object(object) = value { - Some(object) - } else { - None - } -} +// fn into_object(value: Value) -> Option { +// if let Value::Object(object) = value { +// Some(object) +// } else { +// None +// } +// } trait ObjectExt { fn remove_string>(&mut self, key: &'static str) -> ParseResult; fn remove_array(&mut self, key: &'static str) -> ParseResult>; - fn remove_object(&mut self, key: &'static str) -> ParseResult; - fn remove_nullable( - &mut self, - key: &'static str, - f: impl FnOnce(Value) -> Option, - ) -> ParseResult>; + // fn remove_object(&mut self, key: &'static str) -> ParseResult; + // fn remove_nullable( + // &mut self, + // key: &'static str, + // f: impl FnOnce(Value) -> Option, + // ) -> ParseResult>; } impl ObjectExt for Object { @@ -157,14 +157,14 @@ impl ObjectExt for Object { fn remove_array(&mut self, key: &'static str) -> ParseResult> { self.remove(key).and_then(into_array).ok_or(key) } - fn remove_object(&mut self, key: &'static str) -> ParseResult { - self.remove(key).and_then(into_object).ok_or(key) - } - fn remove_nullable( - &mut self, - key: &'static str, - f: impl FnOnce(Value) -> Option, - ) -> ParseResult> { - self.remove(key).and_then(|v| allow_null(v, f)).ok_or(key) - } + // fn remove_object(&mut self, key: &'static str) -> ParseResult { + // self.remove(key).and_then(into_object).ok_or(key) + // } + // fn remove_nullable( + // &mut self, + // key: &'static str, + // f: impl FnOnce(Value) -> Option, + // ) -> ParseResult> { + // self.remove(key).and_then(|v| allow_null(v, f)).ok_or(key) + // } }