Skip to content

Commit

Permalink
Python - Fix some clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
n1t0 committed Dec 13, 2019
1 parent 1a604cd commit ed7e399
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions bindings/python/src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ impl Tokenizer {
fn encode(&self, sentence: &str, pair: Option<&str>) -> PyResult<Encoding> {
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()
}
Expand All @@ -98,12 +98,11 @@ impl Tokenizer {
})
.collect::<PyResult<Vec<_>>>()?;

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()
}

Expand Down

0 comments on commit ed7e399

Please sign in to comment.