mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-29 03:04:38 +08:00
lifetime bounded TryFromBorrwoedObject
This commit is contained in:
1 parent
0f24d66234
commit
f314328294
15 files changed
+53
-38
No files matched your search
+2
-2
@@ -72,8 +72,8 @@ mod mmap {
|
||||
Copy = 3,
|
||||
}
|
||||
|
||||
impl TryFromBorrowedObject for AccessMode {
|
||||
fn try_from_borrowed_object(vm: &VirtualMachine, obj: &PyObject) -> PyResult<Self> {
|
||||
impl<'a> TryFromBorrowedObject<'a> for AccessMode {
|
||||
fn try_from_borrowed_object(vm: &VirtualMachine, obj: &'a PyObject) -> PyResult<Self> {
|
||||
let i = u32::try_from_borrowed_object(vm, obj)?;
|
||||
Ok(match i {
|
||||
0 => Self::Default,
|
||||
|
||||
@@ -129,8 +129,8 @@ mod resource {
|
||||
}
|
||||
|
||||
struct Limits(libc::rlimit);
|
||||
impl TryFromBorrowedObject for Limits {
|
||||
fn try_from_borrowed_object(vm: &VirtualMachine, obj: &PyObject) -> PyResult<Self> {
|
||||
impl<'a> TryFromBorrowedObject<'a> for Limits {
|
||||
fn try_from_borrowed_object(vm: &VirtualMachine, obj: &'a PyObject) -> PyResult<Self> {
|
||||
let seq: Vec<libc::rlim_t> = obj.try_to_value(vm)?;
|
||||
match *seq {
|
||||
[cur, max] => Ok(Self(libc::rlimit {
|
||||
|
||||
@@ -41,8 +41,8 @@ enum NormalizeForm {
|
||||
Nfkd,
|
||||
}
|
||||
|
||||
impl TryFromBorrowedObject for NormalizeForm {
|
||||
fn try_from_borrowed_object(vm: &VirtualMachine, obj: &PyObject) -> PyResult<Self> {
|
||||
impl<'a> TryFromBorrowedObject<'a> for NormalizeForm {
|
||||
fn try_from_borrowed_object(vm: &VirtualMachine, obj: &'a PyObject) -> PyResult<Self> {
|
||||
obj.try_value_with(
|
||||
|form: &PyStr| {
|
||||
Ok(match form.as_str() {
|
||||
|
||||
+2
-2
@@ -581,8 +581,8 @@ mod zlib {
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFromBorrowedObject for Level {
|
||||
fn try_from_borrowed_object(vm: &VirtualMachine, obj: &PyObject) -> PyResult<Self> {
|
||||
impl<'a> TryFromBorrowedObject<'a> for Level {
|
||||
fn try_from_borrowed_object(vm: &VirtualMachine, obj: &'a PyObject) -> PyResult<Self> {
|
||||
let int: i32 = obj.try_index(vm)?.try_to_primitive(vm)?;
|
||||
Ok(Self::new(int))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user