Type Alias abi_stable::std_types::RCowVal
source · pub type RCowVal<'a, T> = RCow<&'a T, T>;
Expand description
Ffi-safe equivalent of Cow<'a, T>
, either a &T
or T
.
§Example
use abi_stable::std_types::{RCow, RCowVal};
fn foo(x: u8) -> RCowVal<'static, u8> {
if x % 2 == 0 {
RCow::Borrowed(&1)
} else {
RCow::Owned(x * 2)
}
}
assert_eq!(*foo(3), 6);
assert_eq!(*foo(4), 1);
assert_eq!(*foo(5), 10);
assert_eq!(*foo(6), 1);
assert_eq!(*foo(7), 14);
Aliased Type§
enum RCowVal<'a, T> {
Borrowed(&'a T),
Owned(T),
}
Variants§
Trait Implementations§
source§impl<'de, 'a, T> Deserialize<'de> for RCowVal<'a, T>where
T: Clone + Deserialize<'de>,
impl<'de, 'a, T> Deserialize<'de> for RCowVal<'a, T>where
T: Clone + Deserialize<'de>,
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more