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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//! Generic constants for types from the [`alloc`] crate, including `String` and `Vec`.
//!
//! [`alloc`]: https://doc.rust-lang.org/alloc/
//!
use ;
/// An empty `Cow<'_, str>`. Usable to construct a `[Cow<'_, str>; N]`.
///
/// As of Rust 1.51.0, `[Cow::Borrowed(""); LEN]` is not valid,
/// because `Cow<'_, str>` isn't copy,
/// but `[COW_STR_NEW; LEN]` does work, like in the example below.
///
/// # Example
///
/// ```rust
/// use konst::alloc_type::COW_STR_NEW;
///
/// use std::borrow::Cow;
///
/// const SIX_COWS: [Cow<'_, str>; 6] = [COW_STR_NEW; 6];
///
/// let mut cows = SIX_COWS;
///
/// ('a'..='f')
/// .enumerate()
/// .filter(|(i, _)| i % 2 == 0 )
/// .for_each(|(i, c)|{
/// cows[i].to_mut().push(c)
/// });
///
/// assert_eq!(cows, ["a", "", "c", "", "e", ""])
///
/// ```
///
pub const COW_STR_NEW: = Borrowed;
/// An empty `String`. Usable to construct a `[String; N]`.
///
/// As of Rust 1.51.0, `[String::new(); LEN]` is not valid, because `String` isn't copy,
/// but `[STRING_NEW; LEN]` does work, like in the example below.
///
/// # Example
///
/// ```rust
/// use konst::alloc_type::STRING_NEW;
///
/// const STRINGS: [String; 3] = [STRING_NEW; 3];
///
/// let mut strings = STRINGS;
///
/// strings[0].push_str("foo");
/// strings[1].push_str("bar");
/// strings[2].push_str("baz");
///
/// assert_eq!(strings, ["foo", "bar", "baz"]);
///
///
/// ```
///
pub const STRING_NEW: String = Stringnew;
declare_generic_const!
declare_generic_const!