Fix examples with the new #[new] API
This commit is contained in:
parent
e2dc843de5
commit
acb1120c55
|
@ -9,8 +9,8 @@ struct BytesExtractor {}
|
|||
#[pymethods]
|
||||
impl BytesExtractor {
|
||||
#[new]
|
||||
pub fn __new__(obj: &PyRawObject) {
|
||||
obj.init({ BytesExtractor {} });
|
||||
pub fn __new__() -> Self {
|
||||
BytesExtractor {}
|
||||
}
|
||||
|
||||
pub fn from_bytes(&mut self, bytes: &PyBytes) -> PyResult<usize> {
|
||||
|
|
|
@ -195,8 +195,8 @@ pub struct TzClass {}
|
|||
#[pymethods]
|
||||
impl TzClass {
|
||||
#[new]
|
||||
fn new(obj: &PyRawObject) {
|
||||
obj.init(TzClass {})
|
||||
fn new() -> Self {
|
||||
TzClass {}
|
||||
}
|
||||
|
||||
fn utcoffset<'p>(&self, py: Python<'p>, _dt: &PyDateTime) -> PyResult<&'p PyDelta> {
|
||||
|
|
|
@ -16,8 +16,8 @@ pub struct DictSize {
|
|||
#[pymethods]
|
||||
impl DictSize {
|
||||
#[new]
|
||||
fn new(obj: &PyRawObject, expected: u32) {
|
||||
obj.init(DictSize { expected })
|
||||
fn new(expected: u32) -> Self {
|
||||
DictSize { expected }
|
||||
}
|
||||
|
||||
fn iter_dict(&mut self, _py: Python<'_>, dict: &PyDict) -> PyResult<u32> {
|
||||
|
|
|
@ -13,10 +13,10 @@ pub struct ModClass {
|
|||
#[pymethods]
|
||||
impl ModClass {
|
||||
#[new]
|
||||
fn new(obj: &PyRawObject) {
|
||||
obj.init(ModClass {
|
||||
fn new() -> Self {
|
||||
ModClass {
|
||||
_somefield: String::from("contents"),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn noop(&self, x: usize) -> usize {
|
||||
|
|
|
@ -8,8 +8,8 @@ pub struct Subclassable {}
|
|||
#[pymethods]
|
||||
impl Subclassable {
|
||||
#[new]
|
||||
fn new(obj: &PyRawObject) {
|
||||
obj.init(Subclassable {});
|
||||
fn new() -> Self {
|
||||
Subclassable {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,10 +16,10 @@ struct WordCounter {
|
|||
#[pymethods]
|
||||
impl WordCounter {
|
||||
#[new]
|
||||
fn new(obj: &PyRawObject, path: String) {
|
||||
obj.init(WordCounter {
|
||||
fn new(path: String) -> Self {
|
||||
WordCounter {
|
||||
path: PathBuf::from(path),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Searches for the word, parallelized by rayon
|
||||
|
|
|
@ -318,8 +318,9 @@ impl PyTimeAccess for PyTime {
|
|||
///
|
||||
/// This is an abstract base class and should not be constructed directly.
|
||||
pub struct PyTzInfo(PyObject, Unsendable);
|
||||
pyobject_native_var_type!(
|
||||
pyobject_native_type!(
|
||||
PyTzInfo,
|
||||
crate::ffi::PyObject,
|
||||
*PyDateTimeAPI.TZInfoType,
|
||||
Some("datetime"),
|
||||
PyTZInfo_Check
|
||||
|
|
Loading…
Reference in New Issue