@@ -308,6 +308,7 @@ impl CString {
308
308
/// let _ = CString::from_raw(ptr);
309
309
/// }
310
310
/// ```
311
+ #[ inline]
311
312
#[ stable( feature = "cstr_memory" , since = "1.4.0" ) ]
312
313
pub fn into_raw ( self ) -> * mut c_char {
313
314
Box :: into_raw ( self . into_inner ( ) ) as * mut c_char
@@ -382,6 +383,7 @@ impl CString {
382
383
/// let bytes = c_string.as_bytes();
383
384
/// assert_eq!(bytes, &[b'f', b'o', b'o']);
384
385
/// ```
386
+ #[ inline]
385
387
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
386
388
pub fn as_bytes ( & self ) -> & [ u8 ] {
387
389
& self . inner [ ..self . inner . len ( ) - 1 ]
@@ -401,6 +403,7 @@ impl CString {
401
403
/// let bytes = c_string.as_bytes_with_nul();
402
404
/// assert_eq!(bytes, &[b'f', b'o', b'o', b'\0']);
403
405
/// ```
406
+ #[ inline]
404
407
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
405
408
pub fn as_bytes_with_nul ( & self ) -> & [ u8 ] {
406
409
& self . inner
@@ -409,6 +412,7 @@ impl CString {
409
412
/// Extracts a [`CStr`] slice containing the entire string.
410
413
///
411
414
/// [`CStr`]: struct.CStr.html
415
+ #[ inline]
412
416
#[ unstable( feature = "as_c_str" , issue = "40380" ) ]
413
417
pub fn as_c_str ( & self ) -> & CStr {
414
418
& * self
@@ -449,6 +453,7 @@ impl Drop for CString {
449
453
impl ops:: Deref for CString {
450
454
type Target = CStr ;
451
455
456
+ #[ inline]
452
457
fn deref ( & self ) -> & CStr {
453
458
unsafe { CStr :: from_bytes_with_nul_unchecked ( self . as_bytes_with_nul ( ) ) }
454
459
}
@@ -463,6 +468,7 @@ impl fmt::Debug for CString {
463
468
464
469
#[ stable( feature = "cstring_into" , since = "1.7.0" ) ]
465
470
impl From < CString > for Vec < u8 > {
471
+ #[ inline]
466
472
fn from ( s : CString ) -> Vec < u8 > {
467
473
s. into_bytes ( )
468
474
}
@@ -498,6 +504,7 @@ impl Default for CString {
498
504
499
505
#[ stable( feature = "cstr_borrow" , since = "1.3.0" ) ]
500
506
impl Borrow < CStr > for CString {
507
+ #[ inline]
501
508
fn borrow ( & self ) -> & CStr { self }
502
509
}
503
510
@@ -511,13 +518,15 @@ impl<'a> From<&'a CStr> for Box<CStr> {
511
518
512
519
#[ stable( feature = "c_string_from_box" , since = "1.18.0" ) ]
513
520
impl From < Box < CStr > > for CString {
521
+ #[ inline]
514
522
fn from ( s : Box < CStr > ) -> CString {
515
523
s. into_c_string ( )
516
524
}
517
525
}
518
526
519
527
#[ stable( feature = "box_from_c_string" , since = "1.18.0" ) ]
520
528
impl Into < Box < CStr > > for CString {
529
+ #[ inline]
521
530
fn into ( self ) -> Box < CStr > {
522
531
self . into_boxed_c_str ( )
523
532
}
@@ -730,6 +739,7 @@ impl CStr {
730
739
/// assert_eq!(cstr, &*cstring);
731
740
/// }
732
741
/// ```
742
+ #[ inline]
733
743
#[ stable( feature = "cstr_from_bytes" , since = "1.10.0" ) ]
734
744
pub unsafe fn from_bytes_with_nul_unchecked ( bytes : & [ u8 ] ) -> & CStr {
735
745
mem:: transmute ( bytes)
@@ -772,6 +782,7 @@ impl CStr {
772
782
/// *ptr;
773
783
/// }
774
784
/// ```
785
+ #[ inline]
775
786
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
776
787
pub fn as_ptr ( & self ) -> * const c_char {
777
788
self . inner . as_ptr ( )
@@ -789,6 +800,7 @@ impl CStr {
789
800
/// > **Note**: This method is currently implemented as a 0-cost cast, but
790
801
/// > it is planned to alter its definition in the future to perform the
791
802
/// > length calculation whenever this method is called.
803
+ #[ inline]
792
804
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
793
805
pub fn to_bytes ( & self ) -> & [ u8 ] {
794
806
let bytes = self . to_bytes_with_nul ( ) ;
@@ -805,6 +817,7 @@ impl CStr {
805
817
/// > length calculation whenever this method is called.
806
818
///
807
819
/// [`to_bytes`]: #method.to_bytes
820
+ #[ inline]
808
821
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
809
822
pub fn to_bytes_with_nul ( & self ) -> & [ u8 ] {
810
823
unsafe { mem:: transmute ( & self . inner ) }
@@ -908,13 +921,15 @@ impl ops::Index<ops::RangeFull> for CString {
908
921
909
922
#[ stable( feature = "cstring_asref" , since = "1.7.0" ) ]
910
923
impl AsRef < CStr > for CStr {
924
+ #[ inline]
911
925
fn as_ref ( & self ) -> & CStr {
912
926
self
913
927
}
914
928
}
915
929
916
930
#[ stable( feature = "cstring_asref" , since = "1.7.0" ) ]
917
931
impl AsRef < CStr > for CString {
932
+ #[ inline]
918
933
fn as_ref ( & self ) -> & CStr {
919
934
self
920
935
}
0 commit comments