Switch to i32 for tracking bracket depth.

This commit is contained in:
Tom Alexander 2023-08-29 11:07:00 -04:00
parent 14b1d0526c
commit bd97d2f69d
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
7 changed files with 26 additions and 26 deletions

View File

@ -102,7 +102,7 @@ fn global_prefix<'r, 's>(
}
fn global_prefix_end(
starting_bracket_depth: isize,
starting_bracket_depth: i32,
) -> impl for<'r, 's> Fn(Context<'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
move |context: Context, input: OrgSource<'_>| {
_global_prefix_end(context, input, starting_bracket_depth)
@ -113,7 +113,7 @@ fn global_prefix_end(
fn _global_prefix_end<'r, 's>(
context: Context<'r, 's>,
input: OrgSource<'s>,
starting_bracket_depth: isize,
starting_bracket_depth: i32,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
let current_depth = input.get_bracket_depth() - starting_bracket_depth;
if current_depth < 0 {
@ -154,7 +154,7 @@ fn global_suffix<'r, 's>(
}
fn global_suffix_end(
starting_bracket_depth: isize,
starting_bracket_depth: i32,
) -> impl for<'r, 's> Fn(Context<'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
move |context: Context, input: OrgSource<'_>| {
_global_suffix_end(context, input, starting_bracket_depth)
@ -165,7 +165,7 @@ fn global_suffix_end(
fn _global_suffix_end<'r, 's>(
context: Context<'r, 's>,
input: OrgSource<'s>,
starting_bracket_depth: isize,
starting_bracket_depth: i32,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
let current_depth = input.get_bracket_depth() - starting_bracket_depth;
if current_depth < 0 {

View File

@ -109,7 +109,7 @@ fn key_suffix<'r, 's>(
}
fn key_prefix_end(
starting_bracket_depth: isize,
starting_bracket_depth: i32,
) -> 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 +120,7 @@ fn key_prefix_end(
fn _key_prefix_end<'r, 's>(
context: Context<'r, 's>,
input: OrgSource<'s>,
starting_bracket_depth: isize,
starting_bracket_depth: i32,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
let current_depth = input.get_bracket_depth() - starting_bracket_depth;
if current_depth < 0 {
@ -140,7 +140,7 @@ fn _key_prefix_end<'r, 's>(
}
fn key_suffix_end(
starting_bracket_depth: isize,
starting_bracket_depth: i32,
) -> 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 +151,7 @@ fn key_suffix_end(
fn _key_suffix_end<'r, 's>(
_context: Context<'r, 's>,
input: OrgSource<'s>,
starting_bracket_depth: isize,
starting_bracket_depth: i32,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
let current_depth = input.get_bracket_depth() - starting_bracket_depth;
if current_depth < 0 {

View File

@ -121,7 +121,7 @@ fn footnote_reference_only<'r, 's>(
}
fn footnote_definition_end(
starting_bracket_depth: isize,
starting_bracket_depth: i32,
) -> impl for<'r, 's> Fn(Context<'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
move |context: Context, input: OrgSource<'_>| {
_footnote_definition_end(context, input, starting_bracket_depth)
@ -132,7 +132,7 @@ fn footnote_definition_end(
fn _footnote_definition_end<'r, 's>(
_context: Context<'r, 's>,
input: OrgSource<'s>,
starting_bracket_depth: isize,
starting_bracket_depth: i32,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
let current_depth = input.get_bracket_depth() - starting_bracket_depth;
if current_depth > 0 {

View File

@ -91,7 +91,7 @@ fn header<'r, 's>(
}
fn header_end(
starting_bracket_depth: isize,
starting_bracket_depth: i32,
) -> impl for<'r, 's> Fn(Context<'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
move |context: Context, input: OrgSource<'_>| {
_header_end(context, input, starting_bracket_depth)
@ -102,7 +102,7 @@ fn header_end(
fn _header_end<'r, 's>(
_context: Context<'r, 's>,
input: OrgSource<'s>,
starting_bracket_depth: isize,
starting_bracket_depth: i32,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
let current_depth = input.get_bracket_depth() - starting_bracket_depth;
if current_depth > 0 {
@ -141,7 +141,7 @@ fn argument<'r, 's>(
}
fn argument_end(
starting_parenthesis_depth: isize,
starting_parenthesis_depth: i32,
) -> impl for<'r, 's> Fn(Context<'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
move |context: Context, input: OrgSource<'_>| {
_argument_end(context, input, starting_parenthesis_depth)
@ -152,7 +152,7 @@ fn argument_end(
fn _argument_end<'r, 's>(
_context: Context<'r, 's>,
input: OrgSource<'s>,
starting_parenthesis_depth: isize,
starting_parenthesis_depth: i32,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
let current_depth = input.get_parenthesis_depth() - starting_parenthesis_depth;
if current_depth > 0 {

View File

@ -92,7 +92,7 @@ fn header<'r, 's>(
}
fn header_end(
starting_bracket_depth: isize,
starting_bracket_depth: i32,
) -> impl for<'r, 's> Fn(Context<'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
move |context: Context, input: OrgSource<'_>| {
_header_end(context, input, starting_bracket_depth)
@ -103,7 +103,7 @@ fn header_end(
fn _header_end<'r, 's>(
_context: Context<'r, 's>,
input: OrgSource<'s>,
starting_bracket_depth: isize,
starting_bracket_depth: i32,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
let current_depth = input.get_bracket_depth() - starting_bracket_depth;
if current_depth > 0 {
@ -152,7 +152,7 @@ fn body<'r, 's>(
}
fn body_end(
starting_brace_depth: isize,
starting_brace_depth: i32,
) -> impl for<'r, 's> Fn(Context<'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
move |context: Context, input: OrgSource<'_>| _body_end(context, input, starting_brace_depth)
}
@ -161,7 +161,7 @@ fn body_end(
fn _body_end<'r, 's>(
_context: Context<'r, 's>,
input: OrgSource<'s>,
starting_brace_depth: isize,
starting_brace_depth: i32,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
let current_depth = input.get_brace_depth() - starting_brace_depth;
if current_depth > 0 {

View File

@ -19,9 +19,9 @@ pub struct OrgSource<'s> {
start_of_line: usize,
preceding_character: Option<char>,
line_number: usize,
bracket_depth: isize, // []
brace_depth: isize, // {}
parenthesis_depth: isize, // ()
bracket_depth: i32, // []
brace_depth: i32, // {}
parenthesis_depth: i32, // ()
}
impl<'s> std::fmt::Debug for OrgSource<'s> {
@ -77,15 +77,15 @@ impl<'s> OrgSource<'s> {
self.line_number
}
pub fn get_bracket_depth(&self) -> isize {
pub fn get_bracket_depth(&self) -> i32 {
self.bracket_depth
}
pub fn get_brace_depth(&self) -> isize {
pub fn get_brace_depth(&self) -> i32 {
self.brace_depth
}
pub fn get_parenthesis_depth(&self) -> isize {
pub fn get_parenthesis_depth(&self) -> i32 {
self.parenthesis_depth
}
}

View File

@ -170,7 +170,7 @@ fn script_with_braces<'r, 's>(
}
fn script_with_braces_end(
starting_brace_depth: isize,
starting_brace_depth: i32,
) -> impl for<'r, 's> Fn(Context<'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
move |context: Context, input: OrgSource<'_>| {
_script_with_braces_end(context, input, starting_brace_depth)
@ -181,7 +181,7 @@ fn script_with_braces_end(
fn _script_with_braces_end<'r, 's>(
_context: Context<'r, 's>,
input: OrgSource<'s>,
starting_brace_depth: isize,
starting_brace_depth: i32,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
let current_depth = input.get_brace_depth() - starting_brace_depth;
if current_depth > 0 {