Add #[must_use] to conversions that move self
This commit is contained in:
@@ -532,6 +532,7 @@ impl<'a> Component<'a> {
|
||||
/// let components: Vec<_> = path.components().map(|comp| comp.as_os_str()).collect();
|
||||
/// assert_eq!(&components, &[".", "tmp", "foo", "bar.txt"]);
|
||||
/// ```
|
||||
#[must_use = "`self` will be dropped if the result is not used"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn as_os_str(self) -> &'a OsStr {
|
||||
match self {
|
||||
@@ -1428,6 +1429,7 @@ impl PathBuf {
|
||||
/// let os_str = p.into_os_string();
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use = "`self` will be dropped if the result is not used"]
|
||||
#[inline]
|
||||
pub fn into_os_string(self) -> OsString {
|
||||
self.inner
|
||||
@@ -1435,6 +1437,7 @@ impl PathBuf {
|
||||
|
||||
/// Converts this `PathBuf` into a [boxed](Box) [`Path`].
|
||||
#[stable(feature = "into_boxed_path", since = "1.20.0")]
|
||||
#[must_use = "`self` will be dropped if the result is not used"]
|
||||
#[inline]
|
||||
pub fn into_boxed_path(self) -> Box<Path> {
|
||||
let rw = Box::into_raw(self.inner.into_boxed_os_str()) as *mut Path;
|
||||
|
||||
Reference in New Issue
Block a user