Switch to using a type for bracket depth.

This is to make changing the type easier in the future.
This commit is contained in:
Tom Alexander
2023-08-29 11:18:15 -04:00
parent 27a9b5aeb1
commit f29720e5b9
7 changed files with 34 additions and 26 deletions

View File

@@ -10,6 +10,7 @@ use nom::multi::many_till;
use nom::sequence::preceded;
use nom::sequence::tuple;
use super::org_source::BracketDepth;
use super::org_source::OrgSource;
use super::Context;
use crate::error::CustomError;
@@ -109,7 +110,7 @@ fn key_suffix<'r, 's>(
}
fn key_prefix_end(
starting_bracket_depth: i16,
starting_bracket_depth: BracketDepth,
) -> impl for<'r, 's> Fn(Context<'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
move |context: Context, input: OrgSource<'_>| {
_key_prefix_end(context, input, starting_bracket_depth)
@@ -120,7 +121,7 @@ fn key_prefix_end(
fn _key_prefix_end<'r, 's>(
context: Context<'r, 's>,
input: OrgSource<'s>,
starting_bracket_depth: i16,
starting_bracket_depth: BracketDepth,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
let current_depth = input.get_bracket_depth() - starting_bracket_depth;
if current_depth < 0 {
@@ -140,7 +141,7 @@ fn _key_prefix_end<'r, 's>(
}
fn key_suffix_end(
starting_bracket_depth: i16,
starting_bracket_depth: BracketDepth,
) -> impl for<'r, 's> Fn(Context<'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
move |context: Context, input: OrgSource<'_>| {
_key_suffix_end(context, input, starting_bracket_depth)
@@ -151,7 +152,7 @@ fn key_suffix_end(
fn _key_suffix_end<'r, 's>(
_context: Context<'r, 's>,
input: OrgSource<'s>,
starting_bracket_depth: i16,
starting_bracket_depth: BracketDepth,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
let current_depth = input.get_bracket_depth() - starting_bracket_depth;
if current_depth < 0 {