fn from(p: P) -> FileType {
        let path = p.as_ref();
        // Assume HTML in case of no extension.
        // Note: this is only reasonable for URLs; not paths on disk.
        // For example, `README` without an extension is more likely to be a plaintext file.
        // A better solution would be to also implement `From<Url> for FileType`.
        // Unfortunately that's not possible without refactoring, as
        // `AsRef<Path>` could be implemented for `Url` in the future, which is why
        // `From<Url> for FileType` is not allowed.
        match path
            .extension()
            .and_then(std::ffi::OsStr::to_str)
            .map(str::to_lowercase)
            .as_deref()
        {
            Some("md" | "markdown") => FileType::Markdown,
            Some("htm" | "html") | None => FileType::Html,
            Some(_) => FileType::Plaintext,
        }
    }
/// Detect if the given path points to a Markdown, HTML, or plaintext file.
Detect if the given path points to a Markdown, HTML, or plaintext file.
Detect if the given path points to a Markdown HTML or plaintext file .
fn from(p: P) -> FileType {
        let path = p.as_ref();
        // Assume HTML in case of no extension.
        // Note: this is only reasonable for URLs; not paths on disk.
        // For example, `README` without an extension is more likely to be a plaintext file.
        // A better solution would be to also implement `From<Url> for FileType`.
        // Unfortunately that's not possible without refactoring, as
        // `AsRef<Path>` could be implemented for `Url` in the future, which is why
        // `From<Url> for FileType` is not allowed.
        match path
            .extension()
            .and_then(std::ffi::OsStr::to_str)
            .map(str::to_lowercase)
            .as_deref()
        {
            Some("md" | "markdown") => FileType::Markdown,
            Some("htm" | "html") | None => FileType::Html,
            Some(_) => FileType::Plaintext,
        }
    }
fn from ( p : P ) -> FileType { let path = p . as_ref ( ) ; // Assume HTML in case of no extension. // Note: this is only reasonable for URLs; not paths on disk. // For example, `README` without an extension is more likely to be a plaintext file. // A better solution would be to also implement `From<Url> for FileType`. // Unfortunately that's not possible without refactoring, as // `AsRef<Path>` could be implemented for `Url` in the future, which is why // `From<Url> for FileType` is not allowed. match path . extension ( ) . and_then ( std :: ffi :: OsStr :: to_str ) . map ( str :: to_lowercase ) . as_deref ( ) { Some ( " " | " " ) => FileType :: Markdown , Some ( " " | " " ) | None => FileType :: Html , Some ( _ ) => FileType :: Plaintext , } }
Detect if the given path points to a Markdown, HTML, or plaintext file.
Detect if the given path points to a Markdown HTML or plaintext file .
p
P