Rename BytesExtractor method names to reflect their actions
This commit is contained in:
parent
681996da38
commit
9ff41fcd3b
|
@ -13,14 +13,14 @@ impl BytesExtractor {
|
|||
obj.init({ BytesExtractor {} });
|
||||
}
|
||||
|
||||
pub fn to_vec(&mut self, bytes: &PyBytes) -> PyResult<usize> {
|
||||
pub fn from_bytes(&mut self, bytes: &PyBytes) -> PyResult<usize> {
|
||||
let byte_vec: Vec<u8> = bytes.extract().unwrap();
|
||||
Ok(byte_vec.len())
|
||||
}
|
||||
|
||||
pub fn to_str(&mut self, bytes: &PyString) -> PyResult<usize> {
|
||||
let byte_str: String = bytes.extract().unwrap();
|
||||
Ok(byte_str.len())
|
||||
pub fn from_str(&mut self, string: &PyString) -> PyResult<usize> {
|
||||
let rust_string: String = string.extract().unwrap();
|
||||
Ok(rust_string.len())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,13 +26,13 @@ def test_pybuffer_doesnot_leak_memory():
|
|||
message_b = b'\\(-"-;) Praying that memory leak would not happen..'
|
||||
message_s = '\\(-"-;) Praying that memory leak would not happen..'
|
||||
|
||||
def to_vec():
|
||||
def from_bytes():
|
||||
for i in range(N):
|
||||
extractor.to_vec(message_b)
|
||||
extractor.from_bytes(message_b)
|
||||
|
||||
def to_str():
|
||||
def from_str():
|
||||
for i in range(N):
|
||||
extractor.to_str(message_s)
|
||||
extractor.from_str(message_s)
|
||||
|
||||
assert memory_diff(to_vec) == 0
|
||||
assert memory_diff(to_str) == 0
|
||||
assert memory_diff(from_bytes) == 0
|
||||
assert memory_diff(from_str) == 0
|
||||
|
|
Loading…
Reference in a new issue