paved 0.6.0

A simple platform agnostic path representation
Documentation
use std::path::{Path, PathBuf};

use crate::{PathType, PavedPath};

impl PavedPath {
    /// Create a new [`PavedPath`] with the specified [PathType]
    pub fn new(path_type: PathType) -> Self {
        let mut new_path = Self {
            path_type,
            path_prefix: None,
            directories: Vec::new(),
            file: None,
            inner: PathBuf::new(),
        };

        new_path.rebuild_inner();
        new_path
    }

    /// Wrapper for [`PavedPath::new()`] with default type as [`PathType::Relative`]
    pub fn new_relative() -> Self {
        Self::new(PathType::Relative)
    }

    /// Wrapper for [`PavedPath::new()`] with default type as [`PathType::Absolute`]
    pub fn new_absolute() -> Self {
        Self::new(PathType::Absolute)
    }

    /// Builds a [`Self`] from any type that implements [`AsRef<Path>`], treating every component of the referenced path as a directory
    pub fn from_dirs_path(dirs: impl AsRef<Path>) -> Self {
        let mut paved = Self::from(dirs.as_ref());

        if let Some(file) = paved.get_file() {
            let file = file.clone();
            paved = paved.without_file().with_dir(file);
        }

        paved
    }
}