本文簡要介紹rust語言中 Function std::fs::remove_dir 的用法。
用法
pub fn remove_dir<P: AsRef<Path>>(path: P) -> Result<()>刪除一個空目錄。
特定於平台的行為
該函數當前對應於 Unix 上的 rmdir 函數和 Windows 上的 RemoveDirectory 函數。請注意,這個may change in the future。
錯誤
此函數會在以下情況下返回錯誤,但不僅限於這些情況:
path不存在。path不是目錄。- 用戶沒有刪除提供的
path目錄的權限。 - 目錄不為空。
例子
use std::fs;
fn main() -> std::io::Result<()> {
fs::remove_dir("/some/dir")?;
Ok(())
}相關用法
- Rust remove_dir_all用法及代碼示例
- Rust remove_file用法及代碼示例
- Rust remove_var用法及代碼示例
- Rust rename用法及代碼示例
- Rust read用法及代碼示例
- Rust read_to_string用法及代碼示例
- Rust read_link用法及代碼示例
- Rust resume_unwind用法及代碼示例
- Rust repeat用法及代碼示例
- Rust ready用法及代碼示例
- Rust read_unaligned用法及代碼示例
- Rust read_dir用法及代碼示例
- Rust read_volatile用法及代碼示例
- Rust repeat_with用法及代碼示例
- Rust replace用法及代碼示例
- Rust range用法及代碼示例
- Rust UdpSocket.set_multicast_loop_v6用法及代碼示例
- Rust i64.overflowing_add_unsigned用法及代碼示例
- Rust Box.downcast用法及代碼示例
- Rust BTreeMap.last_key_value用法及代碼示例
- Rust str.make_ascii_uppercase用法及代碼示例
- Rust u128.checked_pow用法及代碼示例
- Rust usize.wrapping_mul用法及代碼示例
- Rust AtomicU8.fetch_sub用法及代碼示例
- Rust PanicInfo.payload用法及代碼示例
注:本文由純淨天空篩選整理自rust-lang.org大神的英文原創作品 Function std::fs::remove_dir。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
