pub trait FromHandle {
// Required method
fn from_handle(owned: OwnedHandle) -> Self;
// Provided method
fn from_into_handle<Owned: Into<OwnedHandle>>(into_owned: Owned) -> Self
where Self: Sized + From<OwnedHandle> { ... }
}
Expand description
A trait to express the ability to construct an object from a handle.
Required Methods§
Sourcefn from_handle(owned: OwnedHandle) -> Self
👎Deprecated since 1.0.0: FromHandle::from_handle
is replaced by From<OwnedHandle>::from
fn from_handle(owned: OwnedHandle) -> Self
FromHandle::from_handle
is replaced by From<OwnedHandle>::from
Constructs a new instance of Self
from the given handle.
§Example
use std::fs::File;
use io_lifetimes::{FromHandle, IntoHandle, OwnedHandle};
let f = File::open("foo.txt")?;
let owned_handle: OwnedHandle = f.into_handle();
let f = File::from_handle(owned_handle);
Provided Methods§
Sourcefn from_into_handle<Owned: Into<OwnedHandle>>(into_owned: Owned) -> Self
fn from_into_handle<Owned: Into<OwnedHandle>>(into_owned: Owned) -> Self
Constructs a new instance of Self
from the given handle converted
from into_owned
.
§Example
use std::fs::File;
use io_lifetimes::{FromHandle, IntoHandle};
let f = File::open("foo.txt")?;
let f = File::from_into_handle(f);
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.