#![cfg_attr(
all(feature = "std", feature = "derive"),
doc = r"
# Derive
```
use std::borrow::Cow;
use ownership::IntoOwned;
#[derive(IntoOwned)]
struct Config<'h, 'c, T> {
name: Cow<'c, str>,
value: T,
#[ownership(as_is)]
help: &'h str, // <- returned as-is
}
```
Generates code functionally equivalent to:
```
use std::borrow::Cow;
use ownership::IntoOwned;
struct Config<'h, 'c, T> {
name: Cow<'c, str>,
value: T,
help: &'h str,
}
impl<'h, 'c, T: IntoOwned> IntoOwned for Config<'h, 'c, T> {
type Owned = Config<'h, 'static, <T as IntoOwned>::Owned>;
fn into_owned(self) -> <Self as IntoOwned>::Owned {
Self::Owned {
name: IntoOwned::into_owned(self.name),
value: IntoOwned::into_owned(self.value),
help: self.help, // <- here
}
}
}
```
"
)]
#![forbid(unsafe_code)]
#![deny(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#[cfg(feature = "alloc")]
extern crate alloc;
pub trait IntoOwned {
type Owned: IntoOwned<Owned = Self::Owned>;
fn into_owned(self) -> Self::Owned;
}
#[cfg(feature = "derive")]
pub use ownership_derive::IntoOwned;
pub mod iterable;
#[macro_use]
pub mod macros;
mod array;
mod cmp;
mod duration;
mod marker;
mod net;
mod never;
mod non_zero;
mod primitive;
mod simple;
mod tuple;
mod unit;
#[cfg(any(feature = "std", feature = "alloc"))]
pub mod cow;
#[cfg(any(feature = "std", feature = "alloc"))]
mod boxed;
#[cfg(any(feature = "std", feature = "alloc"))]
mod c_string;
#[cfg(any(feature = "std", feature = "alloc"))]
mod collections;
#[cfg(any(feature = "std", feature = "alloc"))]
mod string;
#[cfg(any(feature = "std", feature = "alloc"))]
mod vec;
#[cfg(feature = "std")]
mod hash;
#[cfg(feature = "std")]
mod os_string;
#[cfg(feature = "std")]
mod time;