/// @brief 切分路径字符串,返回最左侧那一级的目录名和剩余的部分。 /// /// 举例:对于 /123/456/789/ 本函数返回的第一个值为123, 第二个值为456/789 pub fn split_path(path: &str) -> (&str, Option<&str>) { let mut path_split: core::str::SplitN<&str> = path.trim_matches('/').splitn(2, "/"); let comp = path_split.next().unwrap_or(""); let rest_opt = path_split.next(); return (comp, rest_opt); } /// @brief 切分路径字符串,返回最右侧那一级的目录名和剩余的部分。 /// /// 举例:对于 /123/456/789/ 本函数返回的第一个值为789, 第二个值为123/456 pub fn rsplit_path(path: &str) -> (&str, Option<&str>) { let mut path_split: core::str::RSplitN<&str> = path.trim_matches('/').rsplitn(2, "/"); let comp = path_split.next().unwrap_or(""); let rest_opt = path_split.next(); return (comp, rest_opt); }