From ed7e3999d222477bd252bbe2c1de09dd7c0c6a8f Mon Sep 17 00:00:00 2001 From: Anthony MOI Date: Fri, 13 Dec 2019 18:17:51 -0500 Subject: [PATCH] Python - Fix some clippy warnings --- bindings/python/src/tokenizer.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/bindings/python/src/tokenizer.rs b/bindings/python/src/tokenizer.rs index 6ed3bfe4c..b7f38c918 100644 --- a/bindings/python/src/tokenizer.rs +++ b/bindings/python/src/tokenizer.rs @@ -72,12 +72,12 @@ impl Tokenizer { fn encode(&self, sentence: &str, pair: Option<&str>) -> PyResult { ToPyResult( self.tokenizer - .encode(if pair.is_some() { - tk::tokenizer::EncodeInput::Dual(sentence.to_owned(), pair.unwrap().to_owned()) + .encode(if let Some(pair) = pair { + tk::tokenizer::EncodeInput::Dual(sentence.to_owned(), pair.to_owned()) } else { tk::tokenizer::EncodeInput::Single(sentence.to_owned()) }) - .map(|encoding| Encoding::new(encoding)), + .map(Encoding::new), ) .into() } @@ -98,12 +98,11 @@ impl Tokenizer { }) .collect::>>()?; - ToPyResult(self.tokenizer.encode_batch(inputs).map(|encodings| { - encodings - .into_iter() - .map(|encoding| Encoding::new(encoding)) - .collect() - })) + ToPyResult( + self.tokenizer + .encode_batch(inputs) + .map(|encodings| encodings.into_iter().map(Encoding::new).collect()), + ) .into() }