]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/path.rs
Add #[must_use] to non-mutating verb methods
[rust.git] / library / std / src / path.rs
index 6bfc7b0a5c1dfb89b42a3f79840495da3fa12825..008baa2443f50a7d59b0c46bfbf42d9458e2f1dc 100644 (file)
@@ -1146,6 +1146,7 @@ fn as_mut_vec(&mut self) -> &mut Vec<u8> {
     /// let path = PathBuf::new();
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
+    #[must_use]
     #[inline]
     pub fn new() -> PathBuf {
         PathBuf { inner: OsString::new() }
@@ -1170,6 +1171,7 @@ pub fn new() -> PathBuf {
     ///
     /// [`with_capacity`]: OsString::with_capacity
     #[stable(feature = "path_buf_capacity", since = "1.44.0")]
+    #[must_use]
     #[inline]
     pub fn with_capacity(capacity: usize) -> PathBuf {
         PathBuf { inner: OsString::with_capacity(capacity) }
@@ -2509,6 +2511,8 @@ pub fn iter(&self) -> Iter<'_> {
     /// println!("{}", path.display());
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
+    #[must_use = "this does not display the path, \
+                  it returns an object that can be displayed"]
     #[inline]
     pub fn display(&self) -> Display<'_> {
         Display { path: self }