Skip to content

Commit

Permalink
stylo: Add debug docs assertion in Atom::from_static()
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Aug 16, 2016
1 parent 2b3c684 commit 09cc240
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ports/geckolib/string_cache/lib.rs
Expand Up @@ -171,9 +171,18 @@ impl Atom {
mem::forget(atom);
}

/// Creates an atom from an static atom pointer without checking in release
/// builds.
///
/// Right now it's only used by the atom macro, and ideally it should keep
/// that way, now we have sugar for is_static, creating atoms using
/// Atom::from should involve almost no overhead.
#[inline]
unsafe fn from_static(ptr: *mut nsIAtom) -> Self {
Atom(ptr as *mut WeakAtom)
let atom = Atom(ptr as *mut WeakAtom);
debug_assert!(atom.is_static(),
"Called from_static for a non-static atom!");
atom
}
}

Expand Down

0 comments on commit 09cc240

Please sign in to comment.