1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// devela::sys::mem::view::borrow::ownership
//
//! Defines the [`Ownership`] trait.
//
use ;
/// Defines the relationship between a borrowed type and its owned counterpart.
///
/// This enables abstracting over allocation strategies in [`MaybeOwned`][crate::MaybeOwned].
/// Implement this for types where:
/// - The borrowed form is `&T`
/// - The owned form implements `Borrow<T>` (can be viewed as `&T`)
///
/// # Allocation Requirement
/// This trait's associated type **always requires `alloc`** because:
/// 1. The `Owned` type must implement `Borrow<Self>`
/// 2. Non-alloc owned types would violate the borrowing relationship
///
/// However, the trait itself is `core`-compatible
/// # Examples
/// ```ignore
/// # use devela::{Ownership, MaybeOwned};
/// #[cfg(feature = "alloc")]
/// impl Ownership for str {
/// type Owned = String; // String implements Borrow<str>
/// }
/// ```
///
/// # Alloc Consideration
/// The trait itself is `core`-compatible, but most implementations will require
/// the `alloc` feature for their `Owned` types.
// TODO: helper macro