@@ -322,6 +322,7 @@ impl FromVecWithNulError {
322
322
///
323
323
/// assert_eq!(bytes, value.unwrap_err().into_bytes());
324
324
/// ```
325
+ #[ must_use = "`self` will be dropped if the result is not used" ]
325
326
pub fn into_bytes ( self ) -> Vec < u8 > {
326
327
self . bytes
327
328
}
@@ -524,6 +525,7 @@ impl CString {
524
525
/// }
525
526
/// ```
526
527
#[ inline]
528
+ #[ must_use = "`self` will be dropped if the result is not used" ]
527
529
#[ stable( feature = "cstr_memory" , since = "1.4.0" ) ]
528
530
pub fn into_raw ( self ) -> * mut c_char {
529
531
Box :: into_raw ( self . into_inner ( ) ) as * mut c_char
@@ -547,7 +549,6 @@ impl CString {
547
549
/// let err = cstring.into_string().err().expect("into_string().err() failed");
548
550
/// assert_eq!(err.utf8_error().valid_up_to(), 1);
549
551
/// ```
550
-
551
552
#[ stable( feature = "cstring_into" , since = "1.7.0" ) ]
552
553
pub fn into_string ( self ) -> Result < String , IntoStringError > {
553
554
String :: from_utf8 ( self . into_bytes ( ) ) . map_err ( |e| IntoStringError {
@@ -571,6 +572,7 @@ impl CString {
571
572
/// let bytes = c_string.into_bytes();
572
573
/// assert_eq!(bytes, vec![b'f', b'o', b'o']);
573
574
/// ```
575
+ #[ must_use = "`self` will be dropped if the result is not used" ]
574
576
#[ stable( feature = "cstring_into" , since = "1.7.0" ) ]
575
577
pub fn into_bytes ( self ) -> Vec < u8 > {
576
578
let mut vec = self . into_inner ( ) . into_vec ( ) ;
@@ -591,6 +593,7 @@ impl CString {
591
593
/// let bytes = c_string.into_bytes_with_nul();
592
594
/// assert_eq!(bytes, vec![b'f', b'o', b'o', b'\0']);
593
595
/// ```
596
+ #[ must_use = "`self` will be dropped if the result is not used" ]
594
597
#[ stable( feature = "cstring_into" , since = "1.7.0" ) ]
595
598
pub fn into_bytes_with_nul ( self ) -> Vec < u8 > {
596
599
self . into_inner ( ) . into_vec ( )
@@ -667,6 +670,7 @@ impl CString {
667
670
/// assert_eq!(&*boxed,
668
671
/// CStr::from_bytes_with_nul(b"foo\0").expect("CStr::from_bytes_with_nul failed"));
669
672
/// ```
673
+ #[ must_use = "`self` will be dropped if the result is not used" ]
670
674
#[ stable( feature = "into_boxed_c_str" , since = "1.20.0" ) ]
671
675
pub fn into_boxed_c_str ( self ) -> Box < CStr > {
672
676
unsafe { Box :: from_raw ( Box :: into_raw ( self . into_inner ( ) ) as * mut CStr ) }
@@ -1018,6 +1022,7 @@ impl NulError {
1018
1022
/// let nul_error = CString::new("foo\0bar").unwrap_err();
1019
1023
/// assert_eq!(nul_error.into_vec(), b"foo\0bar");
1020
1024
/// ```
1025
+ #[ must_use = "`self` will be dropped if the result is not used" ]
1021
1026
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1022
1027
pub fn into_vec ( self ) -> Vec < u8 > {
1023
1028
self . 1
@@ -1092,6 +1097,7 @@ impl fmt::Display for FromVecWithNulError {
1092
1097
impl IntoStringError {
1093
1098
/// Consumes this error, returning original [`CString`] which generated the
1094
1099
/// error.
1100
+ #[ must_use = "`self` will be dropped if the result is not used" ]
1095
1101
#[ stable( feature = "cstring_into" , since = "1.7.0" ) ]
1096
1102
pub fn into_cstring ( self ) -> CString {
1097
1103
self . inner
0 commit comments