Python - Update bindings for Replace Normalizer

This commit is contained in:
Anthony MOI
2020-09-23 16:10:29 -04:00
committed by Anthony MOI
parent 41e74248f3
commit 8308508577
3 changed files with 17 additions and 3 deletions

View File

@ -5,7 +5,7 @@ use pyo3::prelude::*;
use pyo3::types::*;
use crate::error::ToPyResult;
use crate::utils::{PyNormalizedString, PyNormalizedStringRefMut};
use crate::utils::{PyNormalizedString, PyNormalizedStringRefMut, PyPattern};
use serde::ser::SerializeStruct;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use tk::normalizers::{
@ -425,8 +425,11 @@ pub struct PyReplace {}
#[pymethods]
impl PyReplace {
#[new]
fn new(pattern: String, content: String) -> PyResult<(Self, PyNormalizer)> {
Ok((PyReplace {}, Replace::new(pattern, content).into()))
fn new(pattern: PyPattern, content: String) -> PyResult<(Self, PyNormalizer)> {
Ok((
PyReplace {},
ToPyResult(Replace::new(pattern, content)).into_py()?.into(),
))
}
}