Get the parent path of a file path. Returns `None` if the path has no parent (is a top-level file).
(path: &str)
| 692 | /// |
| 693 | /// Returns `None` if the path has no parent (is a top-level file). |
| 694 | fn path_parent(path: &str) -> Option<String> { |
| 695 | let path = path.trim_end_matches('/'); |
| 696 | match path.rfind('/') { |
| 697 | Some(pos) if pos > 0 => Some(path[..pos].to_string()), |
| 698 | _ => None, |
| 699 | } |
| 700 | } |
| 701 | |
| 702 | // TESTS |
| 703 |
no outgoing calls
no test coverage detected