pub fn split_path(path: &str) -> (Option<&str>, &str)
Expand description

Splits off the last component of a path.

The path should be a path to a file, and not a directory. If this path is a directory or the root path, the result is undefined.

This attempts to detect Windows or Unix paths and split off the last component of the path accordingly. Note that for paths with mixed slash and backslash separators this might not lead to the desired results.

Note: For a version that operates on byte slices, see split_path_bytes.

Examples

Split the last component of a UNIX path:

assert_eq!(symbolic_common::split_path("/a/b/c"), (Some("/a/b"), "c"));

Split the last component of a Windows path:

assert_eq!(symbolic_common::split_path("C:\\a\\b"), (Some("C:\\a"), "b"));