Skip to content

Commit 9d2e9b9

Browse files
committed
auto merge of #20859 : mahkoh/rust/as_mut_vec, r=nikomatsakis
Closes #20822
2 parents 71a71ce + a03ae68 commit 9d2e9b9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/libcollections/string.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ impl String {
302302
/// assert_eq!(String::from_utf16_lossy(v),
303303
/// "𝄞mus\u{FFFD}ic\u{FFFD}".to_string());
304304
/// ```
305+
#[inline]
305306
#[stable]
306307
pub fn from_utf16_lossy(v: &[u16]) -> String {
307308
unicode_str::utf16_items(v).map(|c| c.to_char_lossy()).collect()
@@ -556,6 +557,7 @@ impl String {
556557
/// assert_eq!(s.remove(1), 'o');
557558
/// assert_eq!(s.remove(0), 'o');
558559
/// ```
560+
#[inline]
559561
#[stable]
560562
pub fn remove(&mut self, idx: uint) -> char {
561563
let len = self.len();
@@ -582,6 +584,7 @@ impl String {
582584
///
583585
/// If `idx` does not lie on a character boundary or is out of bounds, then
584586
/// this function will panic.
587+
#[inline]
585588
#[stable]
586589
pub fn insert(&mut self, idx: uint, ch: char) {
587590
let len = self.len();
@@ -618,6 +621,7 @@ impl String {
618621
/// }
619622
/// assert_eq!(s.as_slice(), "olleh");
620623
/// ```
624+
#[inline]
621625
#[stable]
622626
pub unsafe fn as_mut_vec<'a>(&'a mut self) -> &'a mut Vec<u8> {
623627
&mut self.vec
@@ -645,6 +649,7 @@ impl String {
645649
/// v.push('a');
646650
/// assert!(!v.is_empty());
647651
/// ```
652+
#[inline]
648653
#[stable]
649654
pub fn is_empty(&self) -> bool { self.len() == 0 }
650655

@@ -801,6 +806,7 @@ impl Str for String {
801806

802807
#[stable]
803808
impl Default for String {
809+
#[inline]
804810
#[stable]
805811
fn default() -> String {
806812
String::new()
@@ -809,13 +815,15 @@ impl Default for String {
809815

810816
#[stable]
811817
impl fmt::String for String {
818+
#[inline]
812819
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
813820
fmt::String::fmt(&**self, f)
814821
}
815822
}
816823

817824
#[unstable = "waiting on fmt stabilization"]
818825
impl fmt::Show for String {
826+
#[inline]
819827
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
820828
fmt::Show::fmt(&**self, f)
821829
}
@@ -842,6 +850,7 @@ impl<H: hash::Writer + hash::Hasher> hash::Hash<H> for String {
842850
impl<'a> Add<&'a str> for String {
843851
type Output = String;
844852

853+
#[inline]
845854
fn add(mut self, other: &str) -> String {
846855
self.push_str(other);
847856
self
@@ -881,6 +890,7 @@ impl ops::Index<ops::FullRange> for String {
881890
impl ops::Deref for String {
882891
type Target = str;
883892

893+
#[inline]
884894
fn deref<'a>(&'a self) -> &'a str {
885895
unsafe { mem::transmute(&self.vec[]) }
886896
}
@@ -895,6 +905,7 @@ pub struct DerefString<'a> {
895905
impl<'a> Deref for DerefString<'a> {
896906
type Target = String;
897907

908+
#[inline]
898909
fn deref<'b>(&'b self) -> &'b String {
899910
unsafe { mem::transmute(&*self.x) }
900911
}
@@ -933,6 +944,7 @@ pub trait ToString {
933944
}
934945

935946
impl<T: fmt::String + ?Sized> ToString for T {
947+
#[inline]
936948
fn to_string(&self) -> String {
937949
use core::fmt::Writer;
938950
let mut buf = String::new();
@@ -943,12 +955,14 @@ impl<T: fmt::String + ?Sized> ToString for T {
943955
}
944956

945957
impl IntoCow<'static, String, str> for String {
958+
#[inline]
946959
fn into_cow(self) -> CowString<'static> {
947960
Cow::Owned(self)
948961
}
949962
}
950963

951964
impl<'a> IntoCow<'a, String, str> for &'a str {
965+
#[inline]
952966
fn into_cow(self) -> CowString<'a> {
953967
Cow::Borrowed(self)
954968
}
@@ -966,6 +980,7 @@ impl<'a> Str for CowString<'a> {
966980
}
967981

968982
impl fmt::Writer for String {
983+
#[inline]
969984
fn write_str(&mut self, s: &str) -> fmt::Result {
970985
self.push_str(s);
971986
Ok(())

0 commit comments

Comments
 (0)