supa_mdx_lint/
utils.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
mod char_tree;
pub(crate) mod lru;
pub(crate) mod mdast;
pub(crate) mod path;
pub(crate) mod regex;
pub(crate) mod words;

use std::path::Path;

pub fn is_lintable(path: impl AsRef<Path>) -> bool {
    let path = path.as_ref();
    path.is_dir() || path.extension().map_or(false, |ext| ext == "mdx")
}

pub trait Offsets {
    fn start(&self) -> usize;
    fn end(&self) -> usize;
}

impl<T: Offsets> Offsets for &T {
    fn start(&self) -> usize {
        (*self).start()
    }

    fn end(&self) -> usize {
        (*self).end()
    }
}