Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6a04dfe

Browse files
committed
Renamestd::fs::try_exists tostd::fs::exists and stabilize fs_try_exists
1 parente3c3ce6 commit6a04dfe

File tree

10 files changed

+18
-19
lines changed

10 files changed

+18
-19
lines changed

‎library/std/src/fs.rs‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2739,18 +2739,15 @@ impl AsInnerMut<fs_imp::DirBuilder> for DirBuilder {
27392739
/// # Examples
27402740
///
27412741
/// ```no_run
2742-
/// #![feature(fs_try_exists)]
27432742
/// use std::fs;
27442743
///
2745-
/// assert!(!fs::try_exists("does_not_exist.txt").expect("Can't check existence of file does_not_exist.txt"));
2746-
/// assert!(fs::try_exists("/root/secret_file.txt").is_err());
2744+
/// assert!(!fs::exists("does_not_exist.txt").expect("Can't check existence of file does_not_exist.txt"));
2745+
/// assert!(fs::exists("/root/secret_file.txt").is_err());
27472746
/// ```
27482747
///
27492748
/// [`Path::exists`]: crate::path::Path::exists
2750-
// FIXME: stabilization should modify documentation of `exists()` to recommend this method
2751-
// instead.
2752-
#[unstable(feature ="fs_try_exists", issue ="83186")]
2749+
#[stable(feature ="fs_try_exists", since ="CURRENT_RUSTC_VERSION")]
27532750
#[inline]
2754-
pubfntry_exists<P:AsRef<Path>>(path:P) -> io::Result<bool>{
2755-
fs_imp::try_exists(path.as_ref())
2751+
pubfnexists<P:AsRef<Path>>(path:P) -> io::Result<bool>{
2752+
fs_imp::exists(path.as_ref())
27562753
}

‎library/std/src/path.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2888,6 +2888,8 @@ impl Path {
28882888
/// prevent time-of-check to time-of-use (TOCTOU) bugs. You should only use it in scenarios
28892889
/// where those bugs are not an issue.
28902890
///
2891+
/// This is an alias for [`std::fs::exists`](crate::fs::exists).
2892+
///
28912893
/// # Examples
28922894
///
28932895
/// ```no_run
@@ -2900,7 +2902,7 @@ impl Path {
29002902
#[stable(feature ="path_try_exists", since ="1.63.0")]
29012903
#[inline]
29022904
pubfntry_exists(&self) -> io::Result<bool>{
2903-
fs::try_exists(self)
2905+
fs::exists(self)
29042906
}
29052907

29062908
/// Returns `true` if the path exists on disk and is pointing at a regular file.

‎library/std/src/sys/pal/hermit/fs.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::sys::time::SystemTime;
1818
usecrate::sys::unsupported;
1919
usecrate::sys_common::{AsInner,AsInnerMut,FromInner,IntoInner};
2020

21-
pubusecrate::sys_common::fs::{copy,try_exists};
21+
pubusecrate::sys_common::fs::{copy,exists};
2222

2323
#[derive(Debug)]
2424
pubstructFile(FileDesc);

‎library/std/src/sys/pal/solid/fs.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::{
1212
sys::unsupported,
1313
};
1414

15-
pubusecrate::sys_common::fs::try_exists;
15+
pubusecrate::sys_common::fs::exists;
1616

1717
/// A file descriptor.
1818
#[derive(Clone,Copy)]

‎library/std/src/sys/pal/unix/fs.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ use libc::{
101101
))]
102102
use libc::{dirent64, fstat64, ftruncate64, lseek64, lstat64, off64_t, open64, stat64};
103103

104-
pubusecrate::sys_common::fs::try_exists;
104+
pubusecrate::sys_common::fs::exists;
105105

106106
pubstructFile(FileDesc);
107107

‎library/std/src/sys/pal/unix/thread.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ mod cgroups {
477477
//! output and we don't unescape
478478
usecrate::borrow::Cow;
479479
usecrate::ffi::OsString;
480-
usecrate::fs::{try_exists,File};
480+
usecrate::fs::{exists,File};
481481
usecrate::io::Read;
482482
usecrate::io::{BufRead,BufReader};
483483
usecrate::os::unix::ffi::OsStringExt;
@@ -555,7 +555,7 @@ mod cgroups {
555555
path.push("cgroup.controllers");
556556

557557
// skip if we're not looking at cgroup2
558-
ifmatches!(try_exists(&path),Err(_) |Ok(false)){
558+
ifmatches!(exists(&path),Err(_) |Ok(false)){
559559
return usize::MAX;
560560
};
561561

@@ -612,7 +612,7 @@ mod cgroups {
612612
path.push(&group_path);
613613

614614
// skip if we guessed the mount incorrectly
615-
ifmatches!(try_exists(&path),Err(_) |Ok(false)){
615+
ifmatches!(exists(&path),Err(_) |Ok(false)){
616616
continue;
617617
}
618618

‎library/std/src/sys/pal/unsupported/fs.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ pub fn remove_dir_all(_path: &Path) -> io::Result<()> {
291291
unsupported()
292292
}
293293

294-
pubfntry_exists(_path:&Path) -> io::Result<bool>{
294+
pubfnexists(_path:&Path) -> io::Result<bool>{
295295
unsupported()
296296
}
297297

‎library/std/src/sys/pal/wasi/fs.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::sys::time::SystemTime;
1717
usecrate::sys::unsupported;
1818
usecrate::sys_common::{AsInner,FromInner,IntoInner};
1919

20-
pubusecrate::sys_common::fs::try_exists;
20+
pubusecrate::sys_common::fs::exists;
2121

2222
pubstructFile{
2323
fd:WasiFd,

‎library/std/src/sys/pal/windows/fs.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ pub fn junction_point(original: &Path, link: &Path) -> io::Result<()> {
15311531
}
15321532

15331533
// Try to see if a file exists but, unlike `exists`, report I/O errors.
1534-
pubfntry_exists(path:&Path) -> io::Result<bool>{
1534+
pubfnexists(path:&Path) -> io::Result<bool>{
15351535
// Open the file to ensure any symlinks are followed to their target.
15361536
letmut opts =OpenOptions::new();
15371537
// No read, write, etc access rights are needed.

‎library/std/src/sys_common/fs.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn remove_dir_all_recursive(path: &Path) -> io::Result<()> {
4242
fs::remove_dir(path)
4343
}
4444

45-
pubfntry_exists(path:&Path) -> io::Result<bool>{
45+
pubfnexists(path:&Path) -> io::Result<bool>{
4646
match fs::metadata(path){
4747
Ok(_) =>Ok(true),
4848
Err(error)if error.kind() == io::ErrorKind::NotFound =>Ok(false),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp