Skip to content

Commit

Permalink
Make fields and methods of TomlParser private so that we can change…
Browse files Browse the repository at this point in the history
… them in future
  • Loading branch information
hoangdt84 authored and knickish committed Jul 19, 2023
1 parent adeff06 commit 60c3c8f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -221,7 +221,7 @@ impl TomlParser {
return Ok(true);
}

pub fn to_val(&mut self, tok: TomlTok, i: &mut Chars) -> Result<Toml, TomlErr> {
fn to_val(&mut self, tok: TomlTok, i: &mut Chars) -> Result<Toml, TomlErr> {
match tok {
TomlTok::BlockOpen => {
let mut vals = Vec::new();
Expand Down Expand Up @@ -252,7 +252,7 @@ impl TomlParser {
}
}

pub fn parse_key_value(
fn parse_key_value(
&mut self,
local_scope: &String,
key: String,
Expand All @@ -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' {
Expand All @@ -288,23 +288,23 @@ 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,
col: self.col,
}
}

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,
col: self.col,
}
}

pub fn next_tok(&mut self, i: &mut Chars) -> Result<TomlTok, TomlErr> {
fn next_tok(&mut self, i: &mut Chars) -> Result<TomlTok, TomlErr> {
while self.cur == '\n' || self.cur == '\r' || self.cur == '\t' || self.cur == ' ' {
self.next(i);
}
Expand Down

0 comments on commit 60c3c8f

Please sign in to comment.