File tree Expand file tree Collapse file tree 2 files changed +35
-4
lines changed Expand file tree Collapse file tree 2 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,6 @@ Safe creation of “CStr” with zero cost at the compilation stage with checkin
14
14
15
15
# Use
16
16
```
17
-
18
17
#![feature(plugin)]
19
18
#![plugin(clucstr)]
20
19
@@ -67,9 +66,25 @@ fn my_function(num: usize, a: &'static CStr) {
67
66
}
68
67
```
69
68
70
- # Panic
69
+ # EasyUse
70
+
71
+ ```
72
+ #![feature(plugin)]
73
+ #![plugin(clucstr)]
74
+
75
+ use std::ffi::CStr;
76
+
77
+ fn main() {
78
+ let cstr = cstr!("My CSTR!");
79
+ //&CStr
80
+
81
+ assert_eq!(cstr.to_bytes(), b"My CSTR!");
82
+ assert_eq!(cstr.to_bytes_with_nul(), b"My CSTR!\0");
83
+ }
71
84
```
72
85
86
+ # Panic
87
+ ```
73
88
#![feature(plugin)]
74
89
#![plugin(clucstr)]
75
90
Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ Safe creation of “CStr” with zero cost at the compilation stage with checkin
27
27
28
28
# Use
29
29
```
30
-
31
30
#![feature(plugin)]
32
31
#![plugin(clucstr)]
33
32
@@ -80,9 +79,26 @@ fn my_function(num: usize, a: &'static CStr) {
80
79
}
81
80
```
82
81
83
- # Panic
82
+ # EasyUse
83
+
84
84
```
85
+ #![feature(plugin)]
86
+ #![plugin(clucstr)]
87
+
88
+ use std::ffi::CStr;
85
89
90
+ fn main() {
91
+ let cstr = cstr!("My CSTR!");
92
+ //&CStr
93
+
94
+ assert_eq!(cstr.to_bytes(), b"My CSTR!");
95
+ assert_eq!(cstr.to_bytes_with_nul(), b"My CSTR!\0");
96
+ }
97
+ ```
98
+
99
+
100
+ # Panic
101
+ ```
86
102
#![feature(plugin)]
87
103
#![plugin(clucstr)]
88
104
You can’t perform that action at this time.
0 commit comments