aboutsummaryrefslogtreecommitdiff
path: root/src/makefile/token.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-03-27 17:02:11 -0600
committerMelody Horn <melody@boringcactus.com>2021-03-27 17:02:11 -0600
commit86c271eb2f9c0b3e1e2a35d26a2dca37435b5b8c (patch)
tree5adc564056cf349793f4b9ffd6c70bf908117cc1 /src/makefile/token.rs
parent5197d769bb2fea50975122a4ebba89c07c712839 (diff)
downloadmakers-86c271eb2f9c0b3e1e2a35d26a2dca37435b5b8c.tar.gz
makers-86c271eb2f9c0b3e1e2a35d26a2dca37435b5b8c.zip
why `pub` when you can `pub(crate)`?
Diffstat (limited to 'src/makefile/token.rs')
-rw-r--r--src/makefile/token.rs22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/makefile/token.rs b/src/makefile/token.rs
index 720055f..4fde3e5 100644
--- a/src/makefile/token.rs
+++ b/src/makefile/token.rs
@@ -12,22 +12,22 @@ use nom::{
};
#[derive(PartialEq, Eq, Clone, Debug)]
-pub struct TokenString(Vec<Token>);
+pub(crate) struct TokenString(Vec<Token>);
impl TokenString {
- pub fn text(text: impl Into<String>) -> Self {
+ pub(crate) fn text(text: impl Into<String>) -> Self {
Self(vec![Token::Text(text.into())])
}
- pub fn tokens(&self) -> impl Iterator<Item = &Token> {
+ pub(crate) fn tokens(&self) -> impl Iterator<Item = &Token> {
self.0.iter()
}
- pub fn first_token_mut(&mut self) -> &mut Token {
+ pub(crate) fn first_token_mut(&mut self) -> &mut Token {
&mut self.0[0]
}
- pub fn split_once(&self, delimiter: char) -> Option<(TokenString, TokenString)> {
+ pub(crate) fn split_once(&self, delimiter: char) -> Option<(TokenString, TokenString)> {
let mut result0 = vec![];
let mut iter = self.0.iter();
while let Some(t) = iter.next() {
@@ -47,14 +47,14 @@ impl TokenString {
None
}
- pub fn ends_with(&self, pattern: &str) -> bool {
+ pub(crate) fn ends_with(&self, pattern: &str) -> bool {
match self.0.last() {
Some(Token::Text(t)) => t.ends_with(pattern),
_ => false,
}
}
- pub fn strip_suffix(&mut self, suffix: &str) {
+ pub(crate) 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()
@@ -62,11 +62,11 @@ impl TokenString {
}
}
- pub fn extend(&mut self, other: TokenString) {
+ pub(crate) fn extend(&mut self, other: TokenString) {
self.0.extend(other.0);
}
- pub fn trim_start(&mut self) {
+ pub(crate) fn trim_start(&mut self) {
if let Some(Token::Text(t)) = self.0.first_mut() {
*t = t.trim_start().into();
}
@@ -83,7 +83,7 @@ impl fmt::Display for TokenString {
}
#[derive(PartialEq, Eq, Clone, Debug)]
-pub enum Token {
+pub(crate) enum Token {
Text(String),
MacroExpansion {
name: String,
@@ -192,7 +192,7 @@ fn full_text_tokens(input: &str) -> IResult<&str, TokenString> {
all_consuming(tokens)(input)
}
-pub fn tokenize(input: &str) -> TokenString {
+pub(crate) fn tokenize(input: &str) -> TokenString {
// TODO handle errors gracefully
let (_, result) = full_text_tokens(input).expect("couldn't parse");
result