Constructor for PyByteArray

This commit is contained in:
Jeong Yunwon
2022-04-27 02:51:36 +09:00
parent 4e7ab31795
commit 9585d2f60a

View File

@@ -95,16 +95,18 @@ pub(crate) fn init(context: &Context) {
#[pyimpl(
flags(BASETYPE),
with(Initializer, Hashable, Comparable, AsBuffer, AsMapping, AsSequence, Iterable)
with(
Constructor,
Initializer,
Hashable,
Comparable,
AsBuffer,
AsMapping,
AsSequence,
Iterable
)
)]
impl PyByteArray {
#[pyslot]
fn slot_new(cls: PyTypeRef, _args: FuncArgs, vm: &VirtualMachine) -> PyResult {
PyByteArray::default()
.into_ref_with_type(vm, cls)
.map(Into::into)
}
#[cfg(debug_assertions)]
#[pyproperty]
fn exports(&self) -> usize {
@@ -706,6 +708,16 @@ impl PyByteArray {
};
}
impl Constructor for PyByteArray {
type Args = FuncArgs;
fn py_new(cls: PyTypeRef, _args: Self::Args, vm: &VirtualMachine) -> PyResult {
PyByteArray::default()
.into_ref_with_type(vm, cls)
.map(Into::into)
}
}
impl Initializer for PyByteArray {
type Args = ByteInnerNewOptions;