diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-06-22 15:24:18 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-06-22 15:24:18 +0200 |
commit | 84008b9a22bdf1af744c1b830241be33d14862ea (patch) | |
tree | fe3dd66a25c2a7c8ffd4ffa4fdf667d816fe1288 /src | |
parent | 227e844154d9a592b80a88d7b8731d3d2f2fb3e2 (diff) | |
download | markdown-rs-84008b9a22bdf1af744c1b830241be33d14862ea.tar.gz markdown-rs-84008b9a22bdf1af744c1b830241be33d14862ea.tar.bz2 markdown-rs-84008b9a22bdf1af744c1b830241be33d14862ea.zip |
Refactor some unneeded assignments
Diffstat (limited to 'src')
-rw-r--r-- | src/construct/code_fenced.rs | 6 | ||||
-rw-r--r-- | src/construct/html_flow.rs | 1 | ||||
-rw-r--r-- | src/subtokenize.rs | 3 | ||||
-rw-r--r-- | src/tokenizer.rs | 4 |
4 files changed, 5 insertions, 9 deletions
diff --git a/src/construct/code_fenced.rs b/src/construct/code_fenced.rs index 3b220b9..5b1426c 100644 --- a/src/construct/code_fenced.rs +++ b/src/construct/code_fenced.rs @@ -224,13 +224,12 @@ fn before_sequence_open(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult /// console.log(1); /// ~~~ /// ``` -fn sequence_open(tokenizer: &mut Tokenizer, code: Code, info: Info) -> StateFnResult { +fn sequence_open(tokenizer: &mut Tokenizer, code: Code, mut info: Info) -> StateFnResult { match code { Code::Char(char) if char == info.kind.as_char() => { tokenizer.consume(code); ( State::Fn(Box::new(|t, c| { - let mut info = info; info.size += 1; sequence_open(t, c, info) })), @@ -277,7 +276,7 @@ fn info_inside( tokenizer: &mut Tokenizer, code: Code, info: Info, - codes: Vec<Code>, + mut codes: Vec<Code>, ) -> StateFnResult { match code { Code::None | Code::CarriageReturnLineFeed | Code::Char('\n' | '\r') => { @@ -293,7 +292,6 @@ fn info_inside( } Code::Char(char) if char == '`' && info.kind == Kind::GraveAccent => (State::Nok, None), Code::Char(_) => { - let mut codes = codes; codes.push(code); tokenizer.consume(code); ( diff --git a/src/construct/html_flow.rs b/src/construct/html_flow.rs index bb7457d..d0e0558 100644 --- a/src/construct/html_flow.rs +++ b/src/construct/html_flow.rs @@ -219,6 +219,7 @@ fn open(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { let mut info = Info { // Assume basic. kind: Kind::Basic, + // Assume closing tag (or no tag). start_tag: false, buffer: vec![], index: 0, diff --git a/src/subtokenize.rs b/src/subtokenize.rs index 1702387..4ee2242 100644 --- a/src/subtokenize.rs +++ b/src/subtokenize.rs @@ -57,8 +57,7 @@ pub fn link(events: &mut [Event], index: usize) { /// Parse linked events. /// /// Supposed to be called repeatedly, returns `1: true` when done. -pub fn subtokenize(events: Vec<Event>, codes: &[Code]) -> (Vec<Event>, bool) { - let mut events = events; +pub fn subtokenize(mut events: Vec<Event>, codes: &[Code]) -> (Vec<Event>, bool) { let mut index = 0; // Map of first chunks to their tokenizer. let mut head_to_tokenizer: HashMap<usize, Tokenizer> = HashMap::new(); diff --git a/src/tokenizer.rs b/src/tokenizer.rs index f76a0f8..7b71308 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -1651,12 +1651,10 @@ impl Tokenizer { /// Used in [`Tokenizer::attempt`][Tokenizer::attempt] and [`Tokenizer::check`][Tokenizer::check]. fn attempt_impl( state: impl FnOnce(&mut Tokenizer, Code) -> StateFnResult + 'static, - codes: Vec<Code>, + mut codes: Vec<Code>, done: impl FnOnce((Vec<Code>, Vec<Code>), bool, &mut Tokenizer) -> StateFnResult + 'static, ) -> Box<StateFn> { Box::new(|tokenizer, code| { - let mut codes = codes; - let (next, remainder) = check_statefn_result(state(tokenizer, code)); match code { |