Merge branch 'master' into is-symlink-stabilization
This commit is contained in:
commit
3e0360f3d4
365 changed files with 4893 additions and 3106 deletions
|
@ -215,6 +215,7 @@ impl<'a> Prefix<'a> {
|
|||
/// assert!(!Disk(b'C').is_verbatim());
|
||||
/// ```
|
||||
#[inline]
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn is_verbatim(&self) -> bool {
|
||||
use self::Prefix::*;
|
||||
|
@ -247,6 +248,7 @@ impl<'a> Prefix<'a> {
|
|||
/// assert!(path::is_separator('/')); // '/' works for both Unix and Windows
|
||||
/// assert!(!path::is_separator('❤'));
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn is_separator(c: char) -> bool {
|
||||
c.is_ascii() && is_sep_byte(c as u8)
|
||||
|
@ -427,6 +429,7 @@ impl<'a> PrefixComponent<'a> {
|
|||
|
||||
/// Returns the raw [`OsStr`] slice for this prefix.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn as_os_str(&self) -> &'a OsStr {
|
||||
self.raw
|
||||
|
@ -532,6 +535,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 {
|
||||
|
@ -675,6 +679,7 @@ impl<'a> Components<'a> {
|
|||
///
|
||||
/// assert_eq!(Path::new("foo/bar.txt"), components.as_path());
|
||||
/// ```
|
||||
#[must_use]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn as_path(&self) -> &'a Path {
|
||||
let mut comps = self.clone();
|
||||
|
@ -820,6 +825,7 @@ impl<'a> Iter<'a> {
|
|||
/// assert_eq!(Path::new("foo/bar.txt"), iter.as_path());
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn as_path(&self) -> &'a Path {
|
||||
self.inner.as_path()
|
||||
|
@ -1145,6 +1151,7 @@ impl PathBuf {
|
|||
/// let path = PathBuf::new();
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn new() -> PathBuf {
|
||||
PathBuf { inner: OsString::new() }
|
||||
|
@ -1169,6 +1176,7 @@ impl 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) }
|
||||
|
@ -1185,6 +1193,7 @@ impl PathBuf {
|
|||
/// assert_eq!(Path::new("/test"), p.as_path());
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn as_path(&self) -> &Path {
|
||||
self
|
||||
|
@ -1428,6 +1437,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 +1445,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;
|
||||
|
@ -1918,6 +1929,7 @@ impl Path {
|
|||
/// assert_eq!(os_str, std::ffi::OsStr::new("foo.txt"));
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn as_os_str(&self) -> &OsStr {
|
||||
&self.inner
|
||||
|
@ -2006,6 +2018,7 @@ impl Path {
|
|||
///
|
||||
/// [`has_root`]: Path::has_root
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
#[allow(deprecated)]
|
||||
pub fn is_absolute(&self) -> bool {
|
||||
if cfg!(target_os = "redox") {
|
||||
|
@ -2030,6 +2043,7 @@ impl Path {
|
|||
///
|
||||
/// [`is_absolute`]: Path::is_absolute
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn is_relative(&self) -> bool {
|
||||
!self.is_absolute()
|
||||
|
@ -2056,6 +2070,7 @@ impl Path {
|
|||
/// assert!(Path::new("/etc/passwd").has_root());
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn has_root(&self) -> bool {
|
||||
self.components().has_root()
|
||||
|
@ -2506,6 +2521,8 @@ impl Path {
|
|||
/// 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 }
|
||||
|
@ -2693,6 +2710,7 @@ impl Path {
|
|||
/// a Unix-like system for example. See [`fs::File::open`] or
|
||||
/// [`fs::OpenOptions::open`] for more information.
|
||||
#[stable(feature = "path_ext", since = "1.5.0")]
|
||||
#[must_use]
|
||||
pub fn is_file(&self) -> bool {
|
||||
fs::metadata(self).map(|m| m.is_file()).unwrap_or(false)
|
||||
}
|
||||
|
@ -2719,6 +2737,7 @@ impl Path {
|
|||
/// check errors, call [`fs::metadata`] and handle its [`Result`]. Then call
|
||||
/// [`fs::Metadata::is_dir`] if it was [`Ok`].
|
||||
#[stable(feature = "path_ext", since = "1.5.0")]
|
||||
#[must_use]
|
||||
pub fn is_dir(&self) -> bool {
|
||||
fs::metadata(self).map(|m| m.is_dir()).unwrap_or(false)
|
||||
}
|
||||
|
@ -2749,6 +2768,7 @@ impl Path {
|
|||
/// This is a convenience function that coerces errors to false. If you want to
|
||||
/// check errors, call [`fs::symlink_metadata`] and handle its [`Result`]. Then call
|
||||
/// [`fs::Metadata::is_symlink`] if it was [`Ok`].
|
||||
#[must_use]
|
||||
#[stable(feature = "is_symlink", since = "1.57.0")]
|
||||
pub fn is_symlink(&self) -> bool {
|
||||
fs::symlink_metadata(self).map(|m| m.is_symlink()).unwrap_or(false)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue