From 9666eea62b8cf763027d1f01acbb403c1c6097e0 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Wed, 31 Mar 2021 13:23:32 -0600 Subject: issuing correction on a previous post of mine, regarding pub(crate) --- src/makefile/token.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/makefile/token.rs') diff --git a/src/makefile/token.rs b/src/makefile/token.rs index 508a779..dee290e 100644 --- a/src/makefile/token.rs +++ b/src/makefile/token.rs @@ -13,29 +13,29 @@ use nom::{ }; #[derive(PartialEq, Eq, Clone, Debug)] -pub(crate) struct TokenString(Vec); +pub struct TokenString(Vec); impl TokenString { - pub(crate) fn text(text: impl Into) -> Self { + pub fn text(text: impl Into) -> Self { Self(vec![Token::Text(text.into())]) } - pub(crate) fn r#macro(name: impl Into) -> Self { + pub fn r#macro(name: impl Into) -> Self { Self(vec![Token::MacroExpansion { name: name.into(), replacement: None, }]) } - pub(crate) fn tokens(&self) -> impl Iterator { + pub fn tokens(&self) -> impl Iterator { self.0.iter() } - pub(crate) fn first_token_mut(&mut self) -> &mut Token { + pub fn first_token_mut(&mut self) -> &mut Token { &mut self.0[0] } - pub(crate) fn split_once(&self, delimiter: char) -> Option<(Self, Self)> { + pub fn split_once(&self, delimiter: char) -> Option<(Self, Self)> { let mut result0 = vec![]; let mut iter = self.0.iter(); while let Some(t) = iter.next() { @@ -55,21 +55,21 @@ impl TokenString { None } - pub(crate) fn starts_with(&self, pattern: &str) -> bool { + pub fn starts_with(&self, pattern: &str) -> bool { match self.0.first() { Some(Token::Text(t)) => t.starts_with(pattern), _ => false, } } - pub(crate) fn ends_with(&self, pattern: &str) -> bool { + pub fn ends_with(&self, pattern: &str) -> bool { match self.0.last() { Some(Token::Text(t)) => t.ends_with(pattern), _ => false, } } - pub(crate) fn strip_prefix(&mut self, suffix: &str) { + pub fn strip_prefix(&mut self, suffix: &str) { if let Some(Token::Text(t)) = self.0.first_mut() { if let Some(x) = t.strip_prefix(suffix) { *t = x.into() @@ -77,7 +77,7 @@ impl TokenString { } } - pub(crate) fn strip_suffix(&mut self, suffix: &str) { + pub fn strip_suffix(&mut self, suffix: &str) { if let Some(Token::Text(t)) = self.0.last_mut() { if let Some(x) = t.strip_suffix(suffix) { *t = x.into() @@ -85,17 +85,17 @@ impl TokenString { } } - pub(crate) fn extend(&mut self, other: Self) { + pub fn extend(&mut self, other: Self) { self.0.extend(other.0); } - pub(crate) fn trim_start(&mut self) { + pub fn trim_start(&mut self) { if let Some(Token::Text(t)) = self.0.first_mut() { *t = t.trim_start().into(); } } - pub(crate) fn trim_end(&mut self) { + pub fn trim_end(&mut self) { if let Some(Token::Text(t)) = self.0.last_mut() { *t = t.trim_end().into(); } @@ -112,7 +112,7 @@ impl fmt::Display for TokenString { } #[derive(PartialEq, Eq, Clone, Debug)] -pub(crate) enum Token { +pub enum Token { Text(String), MacroExpansion { name: String, @@ -251,7 +251,7 @@ fn full_text_tokens(input: &str) -> IResult<&str, TokenString> { all_consuming(tokens_but_not(vec![]))(input) } -pub(crate) fn tokenize(input: &str) -> anyhow::Result { +pub fn tokenize(input: &str) -> anyhow::Result { let (_, result) = full_text_tokens(input) .finish() .map_err(|err| anyhow::anyhow!(err.to_string())) -- cgit v1.2.3