Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions src/inline_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ impl ops::Index<ops::RangeFull> for InlineString {

#[inline]
fn index(&self, _index: ops::RangeFull) -> &str {
self.assert_sanity();
unsafe { str::from_utf8_unchecked(&self.bytes[..self.len()]) }
self.as_ref()
}
}

Expand Down Expand Up @@ -209,9 +208,7 @@ impl ops::IndexMut<ops::RangeFrom<usize>> for InlineString {
impl ops::IndexMut<ops::RangeFull> for InlineString {
#[inline]
fn index_mut(&mut self, _index: ops::RangeFull) -> &mut str {
self.assert_sanity();
let length = self.len();
unsafe { str::from_utf8_unchecked_mut(&mut self.bytes[..length]) }
self.as_mut()
}
}

Expand All @@ -220,17 +217,14 @@ impl ops::Deref for InlineString {

#[inline]
fn deref(&self) -> &str {
self.assert_sanity();
unsafe { str::from_utf8_unchecked(&self.bytes[..self.len()]) }
self.as_ref()
}
}

impl ops::DerefMut for InlineString {
#[inline]
fn deref_mut(&mut self) -> &mut str {
self.assert_sanity();
let length = self.len();
unsafe { str::from_utf8_unchecked_mut(&mut self.bytes[..length]) }
self.as_mut()
}
}

Expand Down