From 148ede7f0f42f0ccb1620b13d91f35d0c7d04c2f Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 29 Jul 2022 10:49:07 +0200 Subject: Refactor to work on bytes (`u8`) --- src/parser.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/parser.rs') diff --git a/src/parser.rs b/src/parser.rs index cc9c256..613b206 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -12,7 +12,7 @@ use crate::{Constructs, Options}; pub struct ParseState<'a> { pub constructs: &'a Constructs, /// List of chars. - pub chars: Vec, + pub bytes: &'a [u8], /// Set of defined identifiers. pub definitions: Vec, } @@ -20,11 +20,10 @@ pub struct ParseState<'a> { /// Turn a string of markdown into events. /// /// Passes the codes back so the compiler can access the source. -pub fn parse<'a>(value: &str, options: &'a Options) -> (Vec, ParseState<'a>) { +pub fn parse<'a>(value: &'a str, options: &'a Options) -> (Vec, ParseState<'a>) { let mut parse_state = ParseState { constructs: &options.constructs, - // To do: change to `u8`s? - chars: value.chars().collect::<_>(), + bytes: value.as_bytes(), definitions: vec![], }; @@ -38,5 +37,6 @@ pub fn parse<'a>(value: &str, options: &'a Options) -> (Vec, ParseState<' }, ); + // To do: return bytes only? (events, parse_state) } -- cgit