Skip to content

Commit

Permalink
Apply clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
jedel1043 committed Nov 6, 2022
1 parent 75d7a85 commit 61805f1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions boa_engine/src/string/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ pub struct JsString {
ptr: TaggedJsString,
}

// JsString should always be pointer sized.
sa::assert_eq_size!(JsString, *const ());

// Safety: `JsString` does not contain any objects which needs to be traced, so this is safe.
unsafe impl Trace for JsString {
unsafe_empty_trace!();
Expand Down Expand Up @@ -944,6 +947,7 @@ mod tests {
fn refcount(&self) -> Option<usize> {
match self.ptr() {
JsStringPtrKind::Heap(inner) => {
// SAFETY: The reference count of `JsString` guarantees that `inner` is always valid.
let inner = unsafe { inner.as_ref() };
Some(inner.refcount.get())
}
Expand All @@ -958,12 +962,6 @@ mod tests {
assert_eq!(*s, "".encode_utf16().collect::<Vec<u16>>());
}

#[test]
fn pointer_size() {
assert_eq!(size_of::<JsString>(), size_of::<*const ()>());
assert_eq!(size_of::<Option<JsString>>(), size_of::<*const ()>());
}

#[test]
fn refcount() {
let x = js_string!("Hello world");
Expand Down

0 comments on commit 61805f1

Please sign in to comment.