From ac5d42b3748e8333f4c6f55af828b3db5f96763e Mon Sep 17 00:00:00 2001 From: Cong-Cong Date: Tue, 19 Mar 2024 10:24:40 +0800 Subject: [PATCH] chore: make struct field private --- src/helpers.rs | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/helpers.rs b/src/helpers.rs index 382e6553..7c5a618e 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -124,34 +124,38 @@ pub struct GeneratedInfo { pub fn decode_mappings<'b, 'a: 'b>( source_map: &'a SourceMap, ) -> impl Iterator + 'b { - SegmentIter { - line: "", - mapping_str: source_map.mappings(), - source_index: 0, - original_line: 1, - original_column: 0, - name_index: 0, - generated_line: 0, - segment_cursor: 0, - generated_column: 0, - nums: Vec::with_capacity(5), - } + SegmentIter::new(source_map.mappings()) } pub struct SegmentIter<'a> { - pub mapping_str: &'a str, - pub generated_line: usize, - pub generated_column: u32, - pub source_index: u32, - pub original_line: u32, - pub original_column: u32, - pub name_index: u32, - pub line: &'a str, - pub nums: Vec, - pub segment_cursor: usize, + mapping_str: &'a str, + generated_line: usize, + generated_column: u32, + source_index: u32, + original_line: u32, + original_column: u32, + name_index: u32, + line: &'a str, + nums: Vec, + segment_cursor: usize, } impl<'a> SegmentIter<'a> { + pub fn new(mapping_str: &'a str) -> Self { + SegmentIter { + line: "", + mapping_str, + source_index: 0, + original_line: 1, + original_column: 0, + name_index: 0, + generated_line: 0, + segment_cursor: 0, + generated_column: 0, + nums: Vec::with_capacity(5), + } + } + fn next_segment(&mut self) -> Option<&'a str> { if self.line.is_empty() { loop {