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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/// Adds two numbers together.
///
/// # Arguments
///
/// * `x` - The first number to add.
/// * `y` - The second number to add.
///
/// # Returns
///
/// The sum of `x` and `y`.
///
/// # Examples
///
/// ```
/// use test_cp_first_lib::add_num;
/// let result = add_num(1, 2);
/// assert_eq!(result, 3);
/// ```
/// `say_hi` Prints a greeting to the console.
///
/// # Arguments
///
/// * `name` - The name to greet.
///
/// # Examples
///
/// ```
/// use test_cp_first_lib::say_hi;
/// say_hi("Alice"); // Prints "Hi Alice!"
/// say_hi("Bob"); // Prints "Hi Bob!"
/// ```
///
/// # Panics
///
/// 如果输入是异常值,则此函数会 panic。
///
/// # Errors
///
/// 这个函数不会返回 `Result`,所以没有错误。
///
/// # Safety
///
/// 这个函数是安全的,不需要额外的前置条件。
///
/// 从字符串中解析一个整数。
///
/// # Arguments
///
/// * `s` - 要解析的字符串。
///
/// # Returns
///
/// 如果解析成功,返回解析后的整数;否则返回错误。
///
/// # Errors
///
/// 如果字符串无法正确解析为整数,会返回 `std::num::ParseIntError`。
///
/// # Panics
///
/// 无。
///
/// # Safety
///
/// - 安全,没有不安全代码。
///
/// # Examples
///
/// ```
/// use test_cp_first_lib::parse_number;
/// let result = parse_number("42");
/// assert_eq!(result, Ok(42));
///
/// let result = parse_number("not_a_number");
/// assert!(result.is_err());
///
/// ```
/// 将一个原始指针转换为可变引用。
///
/// # Safety
///
/// 调用者必须保证:
/// - `ptr` 必须是一个有效的、对齐的、初始化了的 `i32` 类型的指针。
/// - 在同一时间,不能有任何别的可变引用或者不可变引用指向同一块内存(符合 Rust 的别名规则)。
///
/// 如果违反以上任一条件,行为是未定义的(UB)。
///
/// # Examples
///
/// ```
/// use test_cp_first_lib::ptr_to_mut_ref;
///
/// let mut num = 42;
/// let ptr = &mut num as *mut i32;
///
/// let ref_to_num = unsafe { ptr_to_mut_ref(ptr) };
/// *ref_to_num = 24;
///
/// assert_eq!(num, 24);
///
/// ```
pub unsafe
/// 测试 `ptr_to_mut_ref` 函数的!标识。
///
/// ```
/// use test_cp_first_lib::ptr_to_mut_ref;
///
/// let mut num = 42;
/// let ptr = &mut num as *mut i32;
///
/// let ref_to_num = unsafe { ptr_to_mut_ref(ptr) };
/// *ref_to_num = 24;
///
/// assert_eq!(num, 24);
///
/// ```
pub unsafe
pub use SecondaryColor;
pub use mix;
pub use cratePrimaryColor;