Mojo struct
Path
struct Path
The Path object.
Fields
- path (
String
): The underlying path string representation.
Implemented traits
AnyType
,
Boolable
,
CollectionElement
,
CollectionElementNew
,
Copyable
,
EqualityComparable
,
ExplicitlyCopyable
,
Hashable
,
KeyElement
,
Movable
,
PathLike
,
Stringable
,
UnknownDestructibility
,
Writable
Methods
__init__
__init__(out self)
Initializes a path with the current directory.
__init__(out self, path: String)
Initializes a path with the provided path.
Args:
- path (
String
): The file system path.
__init__(out self, *, other: Self)
Copy the object.
Args:
- other (
Self
): The value to copy.
__bool__
__bool__(self) -> Bool
Checks if the path is not empty.
Returns:
True if the path length is greater than zero, and False otherwise.
__eq__
__eq__(self, other: Self) -> Bool
Returns True if the two paths are equal.
Args:
- other (
Self
): The other path to compare against.
Returns:
True if the paths are equal and False otherwise.
__eq__(self, other: String) -> Bool
Returns True if the two paths are equal.
Args:
- other (
String
): The other path to compare against.
Returns:
True if the String and Path are equal, and False otherwise.
__ne__
__ne__(self, other: Self) -> Bool
Returns True if the two paths are not equal.
Args:
- other (
Self
): The other path to compare against.
Returns:
True if the paths are not equal and False otherwise.
__truediv__
__truediv__(self, suffix: Self) -> Self
Joins two paths using the system-defined path separator.
Args:
- suffix (
Self
): The suffix to append to the path.
Returns:
A new path with the suffix appended to the current path.
__truediv__(self, suffix: String) -> Self
Joins two paths using the system-defined path separator.
Args:
- suffix (
String
): The suffix to append to the path.
Returns:
A new path with the suffix appended to the current path.
__itruediv__
__itruediv__(mut self, suffix: String)
Joins two paths using the system-defined path separator.
Args:
- suffix (
String
): The suffix to append to the path.
__str__
__str__(self) -> String
Returns a string representation of the path.
Returns:
A string representation of the path.
write_to
write_to[W: Writer](self, mut writer: W)
Formats this path to the provided Writer.
Parameters: