data Path
Text operations on /-separated paths; nothing touches the file system.
Example:
use std.io { Path }
fn main() io {
let p = Path.of("/var/log") / "app.log"
print("{p.show()} {p.isAbsolute()}")
}Вывод
/var/log/app.log true
@derive(Eq, Hash)
pub(api) data PathПотокобезопасность. an immutable value.
С версии. 1.0.0-beta
Поля
pub(api) text: str | The path as text. |
Методы
of | (text: str) -> PathThe path with this text. |
join | (other: str) -> PathPath.of("a/b").join("c") is a/b/c; an absolute right side replaces the left; empty parts are ignored. |
/ | (a: Path, b: str) -> PathJoins a path and a segment with / (an absolute b replaces a). |
isAbsolute | () -> boolWhether the path starts with /. |
fileName | () -> strLast component (a/b.txt -> b.txt; / and the empty path -> empty). |
parent | () -> Path?Everything before the last component (a/b/c -> a/b, a -> empty, /a -> /), none for / and the empty path. |
extension | () -> strExtension of the file name without the dot (a.tar.gz -> gz); empty if none; .bashrc has none. |
stem | () -> strFile name without the extension (a.tar.gz -> a.tar). |
withExtension | (ext: str) -> PathThe path with its extension replaced by ext (added when there is none). |
components | () -> List<str>Non-empty components (/a//b/ -> a, b). |
normalize | () -> PathRemoves . components and folds .. |
show | () -> strThe path as text. |
toString | () -> strThe path as text. |
Определено в: std/io/io.oxl:814