Remove unused `HeaderLevel` enum

finchie
Nov 11, 2023, 4:17 PM
BFGL6BCMV2MMWEF6ZRTUCKBE2EHKUQRCTPZLFAECZGDANVIEXLUQC

Dependencies

  • [2] CQEA2ZDI Parse evaluated Typst code instead of AST
  • [3] GYTRFADR Support Typst subdirectories
  • [4] MPTQGIIJ Improve `typst_rust_gen` function names
  • [5] BA5Y6VSE Output Rust code using `syn`
  • [6] 2N3KOCP7 Create MVP Pandoc->Rust compiler
  • [7] RAWT2FQS Nest Xilem tuples longer than 10 elements
  • [8] HEIF2O2E Migrate from `pandoc` to `typst` for AST processing
  • [9] YKL5NCLH Import items from `syn`
  • [10] JCYJWUI3 Add support for various text formats

Change contents

  • edit in crates/typser/src/lib.rs at line 4
    [2.24][3.16:44](),[3.1210][3.16:44]()
    use std::num::NonZeroUsize;
  • edit in crates/typser/src/lib.rs at line 18
    [3.33][3.1232:1233](),[3.113][3.1232:1233](),[3.1162][3.1232:1233](),[3.1232][3.1232:1233](),[3.1233][3.114:309](),[3.309][3.458:571](),[3.571][3.398:782](),[3.398][3.398:782]()
    // Safely wrap i64 header levels in an enum
    enum HeaderLevel {
    H1,
    H2,
    H3,
    H4,
    H5,
    H6,
    }
    // This is not TryFrom as there's not really much we can do to handle the error?
    impl From<NonZeroUsize> for HeaderLevel {
    fn from(value: NonZeroUsize) -> Self {
    match value.get() {
    1 => HeaderLevel::H1,
    2 => HeaderLevel::H2,
    3 => HeaderLevel::H3,
    4 => HeaderLevel::H4,
    5 => HeaderLevel::H5,
    6 => HeaderLevel::H6,
    _ => panic!(
    "Unexpected header level! Headers must be in range of 1 to 6 (inclusive), got: {}",
    value
    ),
    }
    }
    }
  • edit in crates/typser/src/lib.rs at line 19
    [3.783][3.783:1119](),[3.297][3.1169:1172](),[3.1169][3.1169:1172]()
    impl From<HeaderLevel> for &str {
    fn from(value: HeaderLevel) -> Self {
    match value {
    HeaderLevel::H1 => "h1",
    HeaderLevel::H2 => "h2",
    HeaderLevel::H3 => "h3",
    HeaderLevel::H4 => "h4",
    HeaderLevel::H5 => "h5",
    HeaderLevel::H6 => "h6",
    }
    }
    }