@@ -84,6 +84,11 @@ impl AsmStr {
84
84
pub fn len ( & self ) -> usize {
85
85
self . bytes . len
86
86
}
87
+ /// Check if the string is empty
88
+ #[ inline]
89
+ pub fn is_empty ( & self ) -> bool {
90
+ self . bytes . len == 0
91
+ }
87
92
}
88
93
unsafe impl StaticReflect for AsmStr {
89
94
const TYPE_INFO : TypeInfo < ' static > = TypeInfo :: Str ;
@@ -94,7 +99,7 @@ impl<'a> From<&'a str> for AsmStr {
94
99
}
95
100
}
96
101
97
- /// A FFI-safe alternative to Rust's [std::optional ::Option].
102
+ /// A FFI-safe alternative to Rust's [std::option ::Option].
98
103
///
99
104
/// Unlike the Rust type, this does not use the null-pointer
100
105
/// optimization.
@@ -141,7 +146,7 @@ impl<T> AsmOption<T> {
141
146
value : MaybeUninit :: uninit ( )
142
147
}
143
148
}
144
- /// An option with a value
149
+ /// Create an option with a value
145
150
#[ inline]
146
151
pub fn some ( value : T ) -> AsmOption < T > {
147
152
AsmOption {
@@ -151,9 +156,12 @@ impl<T> AsmOption<T> {
151
156
}
152
157
/// Assume that this option is valid
153
158
///
154
- /// Technically, it should already be invalid
155
- /// to have undefined internals.
156
- /// However, this is still unsafe as a sort of lint.
159
+ /// This type is often used to ferry things across FFI boundaries,
160
+ /// so it's the callers repsonsibility to be safe with it.
161
+ ///
162
+ /// ## Safety
163
+ /// The caller assumes that the underlying memory is valid.
164
+ /// If not, undefined behavior will result.
157
165
#[ inline]
158
166
pub unsafe fn assume_valid ( self ) -> Option < T > {
159
167
if self . present {
0 commit comments