Skip to content

Commit 1cb90f4

Browse files
authored
Use pub(crate) instead of pub (#471)
Eventually, there will probably be a `crate` visibility specifier that does the same thing as `pub(crate)`. This commit replaces `pub` with `pub(crate)`, so when `crate` is available we can easily switch to it.
1 parent 1521982 commit 1cb90f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+190
-190
lines changed

src/alias.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use crate::common::*;
22

33
#[derive(Debug)]
4-
pub struct Alias<'a> {
5-
pub name: &'a str,
6-
pub target: &'a str,
7-
pub line_number: usize,
8-
pub private: bool,
4+
pub(crate) struct Alias<'a> {
5+
pub(crate) name: &'a str,
6+
pub(crate) target: &'a str,
7+
pub(crate) line_number: usize,
8+
pub(crate) private: bool,
99
}
1010

1111
impl<'a> Display for Alias<'a> {

src/alias_resolver.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::common::*;
22
use CompilationErrorKind::*;
33

4-
pub struct AliasResolver<'a, 'b>
4+
pub(crate) struct AliasResolver<'a, 'b>
55
where
66
'a: 'b,
77
{
@@ -11,7 +11,7 @@ where
1111
}
1212

1313
impl<'a: 'b, 'b> AliasResolver<'a, 'b> {
14-
pub fn resolve_aliases(
14+
pub(crate) fn resolve_aliases(
1515
aliases: &BTreeMap<&'a str, Alias<'a>>,
1616
recipes: &BTreeMap<&'a str, Recipe<'a>>,
1717
alias_tokens: &BTreeMap<&'a str, Token<'a>>,

src/assignment_evaluator.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
use crate::common::*;
22

3-
pub struct AssignmentEvaluator<'a: 'b, 'b> {
4-
pub assignments: &'b BTreeMap<&'a str, Expression<'a>>,
5-
pub invocation_directory: &'b Result<PathBuf, String>,
6-
pub dotenv: &'b BTreeMap<String, String>,
7-
pub dry_run: bool,
8-
pub evaluated: BTreeMap<&'a str, String>,
9-
pub exports: &'b BTreeSet<&'a str>,
10-
pub overrides: &'b BTreeMap<&'b str, &'b str>,
11-
pub quiet: bool,
12-
pub scope: &'b BTreeMap<&'a str, String>,
13-
pub shell: &'b str,
3+
pub(crate) struct AssignmentEvaluator<'a: 'b, 'b> {
4+
pub(crate) assignments: &'b BTreeMap<&'a str, Expression<'a>>,
5+
pub(crate) invocation_directory: &'b Result<PathBuf, String>,
6+
pub(crate) dotenv: &'b BTreeMap<String, String>,
7+
pub(crate) dry_run: bool,
8+
pub(crate) evaluated: BTreeMap<&'a str, String>,
9+
pub(crate) exports: &'b BTreeSet<&'a str>,
10+
pub(crate) overrides: &'b BTreeMap<&'b str, &'b str>,
11+
pub(crate) quiet: bool,
12+
pub(crate) scope: &'b BTreeMap<&'a str, String>,
13+
pub(crate) shell: &'b str,
1414
}
1515

1616
impl<'a, 'b> AssignmentEvaluator<'a, 'b> {
17-
pub fn evaluate_assignments(
17+
pub(crate) fn evaluate_assignments(
1818
assignments: &BTreeMap<&'a str, Expression<'a>>,
1919
invocation_directory: &Result<PathBuf, String>,
2020
dotenv: &'b BTreeMap<String, String>,
@@ -43,7 +43,7 @@ impl<'a, 'b> AssignmentEvaluator<'a, 'b> {
4343
Ok(evaluator.evaluated)
4444
}
4545

46-
pub fn evaluate_line(
46+
pub(crate) fn evaluate_line(
4747
&mut self,
4848
line: &[Fragment<'a>],
4949
arguments: &BTreeMap<&str, Cow<str>>,
@@ -81,7 +81,7 @@ impl<'a, 'b> AssignmentEvaluator<'a, 'b> {
8181
Ok(())
8282
}
8383

84-
pub fn evaluate_expression(
84+
pub(crate) fn evaluate_expression(
8585
&mut self,
8686
expression: &Expression<'a>,
8787
arguments: &BTreeMap<&str, Cow<str>>,

src/assignment_resolver.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::common::*;
22

33
use CompilationErrorKind::*;
44

5-
pub struct AssignmentResolver<'a: 'b, 'b> {
5+
pub(crate) struct AssignmentResolver<'a: 'b, 'b> {
66
assignments: &'b BTreeMap<&'a str, Expression<'a>>,
77
assignment_tokens: &'b BTreeMap<&'a str, Token<'a>>,
88
stack: Vec<&'a str>,
@@ -11,7 +11,7 @@ pub struct AssignmentResolver<'a: 'b, 'b> {
1111
}
1212

1313
impl<'a: 'b, 'b> AssignmentResolver<'a, 'b> {
14-
pub fn resolve_assignments(
14+
pub(crate) fn resolve_assignments(
1515
assignments: &BTreeMap<&'a str, Expression<'a>>,
1616
assignment_tokens: &BTreeMap<&'a str, Token<'a>>,
1717
) -> CompilationResult<'a, ()> {

src/color.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use ansi_term::{ANSIGenericString, Prefix, Style, Suffix};
55
use atty::Stream;
66

77
#[derive(Copy, Clone)]
8-
pub struct Color {
8+
pub(crate) struct Color {
99
use_color: UseColor,
1010
atty: bool,
1111
style: Style,
@@ -31,96 +31,96 @@ impl Color {
3131
}
3232
}
3333

34-
pub fn fmt(fmt: &Formatter) -> Color {
34+
pub(crate) fn fmt(fmt: &Formatter) -> Color {
3535
if fmt.alternate() {
3636
Color::always()
3737
} else {
3838
Color::never()
3939
}
4040
}
4141

42-
pub fn auto() -> Color {
42+
pub(crate) fn auto() -> Color {
4343
Color {
4444
use_color: UseColor::Auto,
4545
..default()
4646
}
4747
}
4848

49-
pub fn always() -> Color {
49+
pub(crate) fn always() -> Color {
5050
Color {
5151
use_color: UseColor::Always,
5252
..default()
5353
}
5454
}
5555

56-
pub fn never() -> Color {
56+
pub(crate) fn never() -> Color {
5757
Color {
5858
use_color: UseColor::Never,
5959
..default()
6060
}
6161
}
6262

63-
pub fn stderr(self) -> Color {
63+
pub(crate) fn stderr(self) -> Color {
6464
self.redirect(Stream::Stderr)
6565
}
6666

67-
pub fn stdout(self) -> Color {
67+
pub(crate) fn stdout(self) -> Color {
6868
self.redirect(Stream::Stdout)
6969
}
7070

71-
pub fn doc(self) -> Color {
71+
pub(crate) fn doc(self) -> Color {
7272
self.restyle(Style::new().fg(Blue))
7373
}
7474

75-
pub fn error(self) -> Color {
75+
pub(crate) fn error(self) -> Color {
7676
self.restyle(Style::new().fg(Red).bold())
7777
}
7878

79-
pub fn warning(self) -> Color {
79+
pub(crate) fn warning(self) -> Color {
8080
self.restyle(Style::new().fg(Yellow).bold())
8181
}
8282

83-
pub fn banner(self) -> Color {
83+
pub(crate) fn banner(self) -> Color {
8484
self.restyle(Style::new().fg(Cyan).bold())
8585
}
8686

87-
pub fn command(self) -> Color {
87+
pub(crate) fn command(self) -> Color {
8888
self.restyle(Style::new().bold())
8989
}
9090

91-
pub fn parameter(self) -> Color {
91+
pub(crate) fn parameter(self) -> Color {
9292
self.restyle(Style::new().fg(Cyan))
9393
}
9494

95-
pub fn message(self) -> Color {
95+
pub(crate) fn message(self) -> Color {
9696
self.restyle(Style::new().bold())
9797
}
9898

99-
pub fn annotation(self) -> Color {
99+
pub(crate) fn annotation(self) -> Color {
100100
self.restyle(Style::new().fg(Purple))
101101
}
102102

103-
pub fn string(self) -> Color {
103+
pub(crate) fn string(self) -> Color {
104104
self.restyle(Style::new().fg(Green))
105105
}
106106

107-
pub fn active(&self) -> bool {
107+
pub(crate) fn active(&self) -> bool {
108108
match self.use_color {
109109
UseColor::Always => true,
110110
UseColor::Never => false,
111111
UseColor::Auto => self.atty,
112112
}
113113
}
114114

115-
pub fn paint<'a>(&self, text: &'a str) -> ANSIGenericString<'a, str> {
115+
pub(crate) fn paint<'a>(&self, text: &'a str) -> ANSIGenericString<'a, str> {
116116
self.effective_style().paint(text)
117117
}
118118

119-
pub fn prefix(&self) -> Prefix {
119+
pub(crate) fn prefix(&self) -> Prefix {
120120
self.effective_style().prefix()
121121
}
122122

123-
pub fn suffix(&self) -> Suffix {
123+
pub(crate) fn suffix(&self) -> Suffix {
124124
self.effective_style().suffix()
125125
}
126126
}

src/command_ext.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::common::*;
22

3-
pub trait CommandExt {
3+
pub(crate) trait CommandExt {
44
fn export_environment_variables<'a>(
55
&mut self,
66
scope: &BTreeMap<&'a str, String>,

src/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ pub(crate) use crate::{
4949
verbosity::Verbosity,
5050
};
5151

52-
pub type CompilationResult<'a, T> = Result<T, CompilationError<'a>>;
52+
pub(crate) type CompilationResult<'a, T> = Result<T, CompilationError<'a>>;
5353

54-
pub type RunResult<'a, T> = Result<T, RuntimeError<'a>>;
54+
pub(crate) type RunResult<'a, T> = Result<T, RuntimeError<'a>>;
5555

5656
#[allow(unused_imports)]
5757
pub(crate) use std::io::prelude::*;

src/compilation_error.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ use crate::common::*;
33
use crate::misc::{maybe_s, show_whitespace, write_error_context, Or};
44

55
#[derive(Debug, PartialEq)]
6-
pub struct CompilationError<'a> {
7-
pub text: &'a str,
8-
pub offset: usize,
9-
pub line: usize,
10-
pub column: usize,
11-
pub width: usize,
12-
pub kind: CompilationErrorKind<'a>,
6+
pub(crate) struct CompilationError<'a> {
7+
pub(crate) text: &'a str,
8+
pub(crate) offset: usize,
9+
pub(crate) line: usize,
10+
pub(crate) column: usize,
11+
pub(crate) width: usize,
12+
pub(crate) kind: CompilationErrorKind<'a>,
1313
}
1414

1515
impl<'a> Display for CompilationError<'a> {

src/compilation_error_kind.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::common::*;
22

33
#[derive(Debug, PartialEq)]
4-
pub enum CompilationErrorKind<'a> {
4+
pub(crate) enum CompilationErrorKind<'a> {
55
AliasShadowsRecipe {
66
alias: &'a str,
77
recipe_line: usize,

src/configuration.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
use crate::common::*;
22

3-
pub const DEFAULT_SHELL: &str = "sh";
3+
pub(crate) const DEFAULT_SHELL: &str = "sh";
44

5-
pub struct Configuration<'a> {
6-
pub dry_run: bool,
7-
pub evaluate: bool,
8-
pub highlight: bool,
9-
pub overrides: BTreeMap<&'a str, &'a str>,
10-
pub quiet: bool,
11-
pub shell: &'a str,
12-
pub color: Color,
13-
pub verbosity: Verbosity,
5+
pub(crate) struct Configuration<'a> {
6+
pub(crate) dry_run: bool,
7+
pub(crate) evaluate: bool,
8+
pub(crate) highlight: bool,
9+
pub(crate) overrides: BTreeMap<&'a str, &'a str>,
10+
pub(crate) quiet: bool,
11+
pub(crate) shell: &'a str,
12+
pub(crate) color: Color,
13+
pub(crate) verbosity: Verbosity,
1414
}
1515

1616
impl<'a> Default for Configuration<'a> {

src/expression.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::common::*;
22

33
#[derive(PartialEq, Debug)]
4-
pub enum Expression<'a> {
4+
pub(crate) enum Expression<'a> {
55
Backtick {
66
raw: &'a str,
77
token: Token<'a>,
@@ -28,11 +28,11 @@ pub enum Expression<'a> {
2828
}
2929

3030
impl<'a> Expression<'a> {
31-
pub fn variables(&'a self) -> Variables<'a> {
31+
pub(crate) fn variables(&'a self) -> Variables<'a> {
3232
Variables::new(self)
3333
}
3434

35-
pub fn functions(&'a self) -> Functions<'a> {
35+
pub(crate) fn functions(&'a self) -> Functions<'a> {
3636
Functions::new(self)
3737
}
3838
}

src/fragment.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use crate::common::*;
22

33
#[derive(PartialEq, Debug)]
4-
pub enum Fragment<'a> {
4+
pub(crate) enum Fragment<'a> {
55
Text { text: Token<'a> },
66
Expression { expression: Expression<'a> },
77
}
88

99
impl<'a> Fragment<'a> {
10-
pub fn continuation(&self) -> bool {
10+
pub(crate) fn continuation(&self) -> bool {
1111
match *self {
1212
Fragment::Text { ref text } => text.lexeme().ends_with('\\'),
1313
_ => false,

0 commit comments

Comments
 (0)