mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1589738 - nsACString::as_str_unchecked should actually check in debug builds. r=nika
Today I reviewed wrong usage of this API. It'd be good if it crashed in debug builds when misused. Differential Revision: https://phabricator.services.mozilla.com/D49778 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
5accccfa94
commit
f9f0e4b318
@ -1086,8 +1086,13 @@ define_string_types! {
|
||||
}
|
||||
|
||||
impl nsACString {
|
||||
#[inline]
|
||||
pub unsafe fn as_str_unchecked(&self) -> &str {
|
||||
str::from_utf8_unchecked(self)
|
||||
if cfg!(debug_assertions) {
|
||||
str::from_utf8(self).expect("Should be utf-8")
|
||||
} else {
|
||||
str::from_utf8_unchecked(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user