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

@@ -11,15 +11,17 @@ use nom::Slice;
use crate::error::CustomError;
use crate::error::MyError;
pub type BracketDepth = i16;
#[derive(Copy, Clone)]
pub struct OrgSource<'s> {
full_source: &'s str,
start: usize,
end: usize, // exclusive
start_of_line: usize,
bracket_depth: i16, // []
brace_depth: i16, // {}
parenthesis_depth: i16, // ()
bracket_depth: BracketDepth, // []
brace_depth: BracketDepth, // {}
parenthesis_depth: BracketDepth, // ()
preceding_character: Option<char>,
}
@@ -71,15 +73,15 @@ impl<'s> OrgSource<'s> {
self.slice(..(other.start - self.start))
}
pub fn get_bracket_depth(&self) -> i16 {
pub fn get_bracket_depth(&self) -> BracketDepth {
self.bracket_depth
}
pub fn get_brace_depth(&self) -> i16 {
pub fn get_brace_depth(&self) -> BracketDepth {
self.brace_depth
}
pub fn get_parenthesis_depth(&self) -> i16 {
pub fn get_parenthesis_depth(&self) -> BracketDepth {
self.parenthesis_depth
}
}