Python - Update API to allow failure

This commit is contained in:
Anthony MOI
2019-12-13 12:20:05 -05:00
parent 1c7be358b7
commit 2a0ad97809
3 changed files with 29 additions and 20 deletions

View File

@ -1,9 +1,10 @@
extern crate tokenizers as tk;
use super::error::{PyError, ToPyResult};
use super::utils::Container;
use pyo3::exceptions;
use pyo3::prelude::*;
use pyo3::types::*;
use tk::tokenizer::Result;
#[pyclass]
pub struct Decoder {
@ -20,7 +21,7 @@ impl Decoder {
}
fn decode(&self, tokens: Vec<String>) -> PyResult<String> {
Ok(self.decoder.execute(|decoder| decoder.decode(tokens)))
ToPyResult(self.decoder.execute(|decoder| decoder.decode(tokens))).into()
}
}