Struct rob::Rob
[−]
[src]
pub struct Rob<'a, T: 'a + ?Sized> { /* fields omitted */ }
The Rob
type. See the crate documentation.
Methods
impl<'a, T: 'a> Rob<'a, T>
[src]
pub fn from_value(value: T) -> Self
[src]
Creates a new Rob
with an owned value.
Example
let x = rob::Rob::from_value(123i32); assert_eq!(*x, 123); assert!(rob::Rob::is_owned(&x));
impl<'a, T: 'a + ?Sized> Rob<'a, T>
[src]
pub fn from_ref(r: &'a T) -> Self
[src]
Creates a new Rob
with a borrowed reference.
Example
let value = 123i32; let x = rob::Rob::from_ref(&value); assert_eq!(*x, 123); assert!(!rob::Rob::is_owned(&x));
pub fn from_box(b: Box<T>) -> Self
[src]
Creates a new Rob
with an owned value that is already boxed.
Example
let x = rob::Rob::from_box(Box::new(123i32)); assert_eq!(*x, 123); assert!(rob::Rob::is_owned(&x));
pub unsafe fn from_raw(ptr: *mut T, is_owned: bool) -> Self
[src]
Creates a new Rob
from a raw pointer and an owned flag. If
is_owned
is true
, ptr
should come from Box::into_raw
.
pub fn into_raw(this: Self) -> (*mut T, bool)
[src]
Consumes this
, returning a raw pointer to the value and a
flag indicating whether the values is owned or not.
pub fn as_ref(this: &Self) -> Option<&'a T>
[src]
If the value is not owned, returns a reference to it with
lifetime 'a
.
pub fn is_owned(this: &Self) -> bool
[src]
Returns whether the value is owned or not.
impl<'a, T: 'a + ?Sized> Rob<'a, T> where
T: ToOwned,
<T as ToOwned>::Owned: Into<Box<T>>,
[src]
T: ToOwned,
<T as ToOwned>::Owned: Into<Box<T>>,
pub fn into_box(this: Self) -> Box<T>
[src]
Consumes this
, returning a Box
containing the value, cloning
it if it was not owned.
pub fn to_mut(this: &mut Self) -> &mut T
[src]
Returns a mutable reference to the value, cloning it if it was not owned.
Trait Implementations
impl<'a, T: 'a + ?Sized> Drop for Rob<'a, T>
[src]
impl<'a, T: 'a> From<T> for Rob<'a, T>
[src]
impl<'a, T: 'a + ?Sized> From<&'a T> for Rob<'a, T>
[src]
impl<'a, T: 'a + ?Sized> From<Box<T>> for Rob<'a, T>
[src]
impl<'a, T: 'a> From<Vec<T>> for Rob<'a, [T]>
[src]
impl<'a> From<String> for Rob<'a, str>
[src]
impl<'a> From<CString> for Rob<'a, CStr>
[src]
impl<'a> From<OsString> for Rob<'a, OsStr>
[src]
impl<'a> From<PathBuf> for Rob<'a, Path>
[src]
impl<'a, T> From<Cow<'a, T>> for Rob<'a, T> where
T: ToOwned,
<T as ToOwned>::Owned: Into<Box<T>>,
[src]
T: ToOwned,
<T as ToOwned>::Owned: Into<Box<T>>,
impl<'a, T: 'a + Clone> Clone for Rob<'a, T>
[src]
fn clone(&self) -> Self
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'a, T: 'a + ?Sized + Debug> Debug for Rob<'a, T>
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<'a, T: 'a + ?Sized + Hash> Hash for Rob<'a, T>
[src]
fn hash<H: Hasher>(&self, state: &mut H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<'a, T: 'a + ?Sized + PartialEq> PartialEq for Rob<'a, T>
[src]
fn eq(&self, other: &Rob<'a, T>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rob<'a, T>) -> bool
[src]
This method tests for !=
.
impl<'a, T: 'a + ?Sized + PartialOrd> PartialOrd for Rob<'a, T>
[src]
fn partial_cmp(&self, other: &Rob<'a, T>) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rob<'a, T>) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rob<'a, T>) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn ge(&self, other: &Rob<'a, T>) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
fn gt(&self, other: &Rob<'a, T>) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
impl<'a, T: 'a + ?Sized> Deref for Rob<'a, T>
[src]
type Target = T
The resulting type after dereferencing.
fn deref(&self) -> &T
[src]
Dereferences the value.