fix typo, fix bytesinner.add now return Vec[u8]

This commit is contained in:
Jimmy Girardet
2019-04-09 14:43:13 +02:00
parent 2940c7cc28
commit 6c745f68dd
2 changed files with 4 additions and 4 deletions

View File

@@ -55,7 +55,7 @@ impl PyByteInner {
} else {
return Err(vm.new_type_error("encoding without a string argument".to_string()));
}
// On ly one argument
// Only one argument
} else {
let value = if let OptionalArg::Present(ival) = val_option {
match_class!(ival.clone(),
@@ -161,14 +161,14 @@ impl PyByteInner {
hasher.finish() as usize
}
pub fn add(&self, other: &PyByteInner, vm: &VirtualMachine) -> PyResult {
pub fn add(&self, other: &PyByteInner, _vm: &VirtualMachine) -> Vec<u8> {
let elements: Vec<u8> = self
.elements
.iter()
.chain(other.elements.iter())
.cloned()
.collect();
Ok(vm.ctx.new_bytes(elements))
elements
}
pub fn contains_bytes(&self, other: &PyByteInner, vm: &VirtualMachine) -> PyResult {

View File

@@ -134,7 +134,7 @@ impl PyBytesRef {
#[pymethod(name = "__add__")]
fn add(self, other: PyObjectRef, vm: &VirtualMachine) -> PyResult {
match_class!(other,
bytes @ PyBytes => self.inner.add(&bytes.inner, vm),
bytes @ PyBytes => Ok(vm.ctx.new_bytes(self.inner.add(&bytes.inner, vm))),
_ => Ok(vm.ctx.not_implemented()))
}