From 60c3c8f933388c8c14667c75d7cb45028fe1a971 Mon Sep 17 00:00:00 2001 From: hoang Date: Sat, 15 Jul 2023 23:49:27 +0700 Subject: [PATCH] Make fields and methods of `TomlParser` private so that we can change them in future --- src/toml.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/toml.rs b/src/toml.rs index 7184900..98de737 100644 --- a/src/toml.rs +++ b/src/toml.rs @@ -20,9 +20,9 @@ use std::collections::HashMap; /// ``` #[derive(Default)] pub struct TomlParser { - pub cur: char, - pub line: usize, - pub col: usize, + cur: char, + line: usize, + col: usize, } /// A TOML parsed token. @@ -221,7 +221,7 @@ impl TomlParser { return Ok(true); } - pub fn to_val(&mut self, tok: TomlTok, i: &mut Chars) -> Result { + fn to_val(&mut self, tok: TomlTok, i: &mut Chars) -> Result { match tok { TomlTok::BlockOpen => { let mut vals = Vec::new(); @@ -252,7 +252,7 @@ impl TomlParser { } } - pub fn parse_key_value( + fn parse_key_value( &mut self, local_scope: &String, key: String, @@ -274,7 +274,7 @@ impl TomlParser { Ok(()) } - pub fn next(&mut self, i: &mut Chars) { + fn next(&mut self, i: &mut Chars) { if let Some(c) = i.next() { self.cur = c; if self.cur == '\n' { @@ -288,7 +288,7 @@ impl TomlParser { } } - pub fn err_token(&self, tok: TomlTok) -> TomlErr { + fn err_token(&self, tok: TomlTok) -> TomlErr { TomlErr { msg: format!("Unexpected token {:?} ", tok), line: self.line, @@ -296,7 +296,7 @@ impl TomlParser { } } - pub fn err_parse(&self, what: &str) -> TomlErr { + fn err_parse(&self, what: &str) -> TomlErr { TomlErr { msg: format!("Cannot parse toml {} ", what), line: self.line, @@ -304,7 +304,7 @@ impl TomlParser { } } - pub fn next_tok(&mut self, i: &mut Chars) -> Result { + fn next_tok(&mut self, i: &mut Chars) -> Result { while self.cur == '\n' || self.cur == '\r' || self.cur == '\t' || self.cur == ' ' { self.next(i); }