pub type RCowSlice<'a, T> = RCow<RSlice<'a, T>, RVec<T>>;
Expand description
Ffi-safe equivalent of Cow<'a, [T]>
, either an RSlice
or RVec
.
§Example
use abi_stable::std_types::{RCow, RCowSlice, RVec};
use std::iter::once;
fn foo(x: &[u32]) -> RCowSlice<'_, u32> {
match x {
[prev @ .., x] if *x == 5 => RCow::from(RVec::from(prev)),
_ => RCow::from(x),
}
}
assert_eq!(foo(&[3, 4]), &[3, 4][..]);
assert_eq!(foo(&[3, 4, 5]), &[3, 4][..]);
assert_eq!(foo(&[3, 4, 5, 6]), &[3, 4, 5, 6][..]);
assert_eq!(foo(&[3, 4, 5, 6, 7]), &[3, 4, 5, 6, 7][..]);
enum RCowSlice<'a, T> {
Borrowed(RSlice<'a, T>),
Owned(RVec<T>),
}
For converting a &'a [T]
to an RCowSlice<'a, T>
,
most useful when converting from &'a [T;N]
because it coerces the array to a slice.
§Example
use abi_stable::std_types::{RCow, RCowSlice};
const C: RCowSlice<'_, u8> = RCow::from_slice(&[3, 5, 8]);
assert_eq!(C, [3, 5, 8]);
Borrows this RCow as a slice.
§Conditional const fn
This function requires the rust_1_64
feature to be const
-callable
§Example
use abi_stable::std_types::RCow;
let cow = RCow::from_slice(&[3, 5, 8]);
assert_eq!(cow.as_slice(), [3, 5, 8])
Converts this type into a shared reference of the (usually inferred) input type.
Immutably borrows from an owned value.
Read more
Deserialize this value from the given Serde deserializer.
Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
The #[repr(Rust)]
equivalent.
Performs the conversion
Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient,
and should not be overridden without very good reason.
This method returns an ordering between
self
and
other
values if one exists.
Read more
Tests less than (for
self
and
other
) and is used by the
<
operator.
Read more
Tests less than or equal to (for
self
and
other
) and is used by the
<=
operator.
Read more
Tests greater than (for
self
and
other
) and is used by the
>
operator.
Read more
Tests greater than or equal to (for
self
and
other
) and is used by
the
>=
operator.
Read more
This method returns an ordering between
self
and
other
values if one exists.
Read more
Tests less than (for
self
and
other
) and is used by the
<
operator.
Read more
Tests less than or equal to (for
self
and
other
) and is used by the
<=
operator.
Read more
Tests greater than (for
self
and
other
) and is used by the
>
operator.
Read more
Tests greater than or equal to (for
self
and
other
) and is used by
the
>=
operator.
Read more
This method returns an ordering between
self
and
other
values if one exists.
Read more
Tests less than (for
self
and
other
) and is used by the
<
operator.
Read more
Tests less than or equal to (for
self
and
other
) and is used by the
<=
operator.
Read more
Tests greater than (for
self
and
other
) and is used by the
>
operator.
Read more
Tests greater than or equal to (for
self
and
other
) and is used by
the
>=
operator.
Read more
This method returns an ordering between
self
and
other
values if one exists.
Read more
Tests less than (for
self
and
other
) and is used by the
<
operator.
Read more
Tests less than or equal to (for
self
and
other
) and is used by the
<=
operator.
Read more
Tests greater than (for
self
and
other
) and is used by the
>
operator.
Read more
Tests greater than or equal to (for
self
and
other
) and is used by
the
>=
operator.
Read more
This method returns an ordering between
self
and
other
values if one exists.
Read more
Tests less than (for
self
and
other
) and is used by the
<
operator.
Read more
Tests less than or equal to (for
self
and
other
) and is used by the
<=
operator.
Read more
Tests greater than (for
self
and
other
) and is used by the
>
operator.
Read more
Tests greater than or equal to (for
self
and
other
) and is used by
the
>=
operator.
Read more
This method returns an ordering between
self
and
other
values if one exists.
Read more
Tests less than (for
self
and
other
) and is used by the
<
operator.
Read more
Tests less than or equal to (for
self
and
other
) and is used by the
<=
operator.
Read more
Tests greater than (for
self
and
other
) and is used by the
>
operator.
Read more
Tests greater than or equal to (for
self
and
other
) and is used by
the
>=
operator.
Read more
This method returns an ordering between
self
and
other
values if one exists.
Read more
Tests less than (for
self
and
other
) and is used by the
<
operator.
Read more
Tests less than or equal to (for
self
and
other
) and is used by the
<=
operator.
Read more
Tests greater than (for
self
and
other
) and is used by the
>
operator.
Read more
Tests greater than or equal to (for
self
and
other
) and is used by
the
>=
operator.
Read more
This method returns an ordering between
self
and
other
values if one exists.
Read more
Tests less than (for
self
and
other
) and is used by the
<
operator.
Read more
Tests less than or equal to (for
self
and
other
) and is used by the
<=
operator.
Read more
Tests greater than (for
self
and
other
) and is used by the
>
operator.
Read more
Tests greater than or equal to (for
self
and
other
) and is used by
the
>=
operator.
Read more