Skip to content

Commit 3b1b8a4

Browse files
committed
Fix clippy lints and incorrect doc links
1 parent c9038e5 commit 3b1b8a4

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/builtins.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ impl AsmStr {
8484
pub fn len(&self) -> usize {
8585
self.bytes.len
8686
}
87+
/// Check if the string is empty
88+
#[inline]
89+
pub fn is_empty(&self) -> bool {
90+
self.bytes.len == 0
91+
}
8792
}
8893
unsafe impl StaticReflect for AsmStr {
8994
const TYPE_INFO: TypeInfo<'static> = TypeInfo::Str;
@@ -94,7 +99,7 @@ impl<'a> From<&'a str> for AsmStr {
9499
}
95100
}
96101

97-
/// A FFI-safe alternative to Rust's [std::optional::Option].
102+
/// A FFI-safe alternative to Rust's [std::option::Option].
98103
///
99104
/// Unlike the Rust type, this does not use the null-pointer
100105
/// optimization.
@@ -141,7 +146,7 @@ impl<T> AsmOption<T> {
141146
value: MaybeUninit::uninit()
142147
}
143148
}
144-
/// An option with a value
149+
/// Create an option with a value
145150
#[inline]
146151
pub fn some(value: T) -> AsmOption<T> {
147152
AsmOption {
@@ -151,9 +156,12 @@ impl<T> AsmOption<T> {
151156
}
152157
/// Assume that this option is valid
153158
///
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.
157165
#[inline]
158166
pub unsafe fn assume_valid(self) -> Option<T> {
159167
if self.present {

src/types.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub enum TypeInfo<'a> {
160160
/// Internally represented by the [AsmStr] structure
161161
#[cfg(feature = "builtins")]
162162
Str,
163-
/// A very simple optional, represented as [AsmOption]
163+
/// A very simple optional, represented as an [AsmOption](crate::builtins::AsmOption)
164164
///
165165
/// This **never** uses the null pointer optimization
166166
#[cfg(feature = "builtins")]
@@ -454,7 +454,7 @@ impl PrimitiveType {
454454
use self::PrimitiveType::*;
455455
use self::IntSize::*;
456456
use self::FloatSize::*;
457-
let static_type = match *self {
457+
match *self {
458458
Unit => &TypeInfo::Unit,
459459
Never => &TypeInfo::Never,
460460
Bool => &TypeInfo::Bool,
@@ -469,8 +469,7 @@ impl PrimitiveType {
469469
Integer { size: Long, signed: false } => &TypeInfo::Integer { size: Long, signed: false },
470470
Float { size: Single } => &TypeInfo::Float { size: Single },
471471
Float { size: Double } => &TypeInfo::Float { size: Double },
472-
};
473-
static_type
472+
}
474473
}
475474

476475
/// The number of bytes this type tales up

0 commit comments

Comments
 (0)