Skip to content

Commit 89d1faf

Browse files
committed
refactor(toml): Expose ScriptSource for reuse
1 parent a0ccb13 commit 89d1faf

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/cargo/util/toml/embedded.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,15 @@ fn sanitize_name(name: &str) -> String {
189189
}
190190

191191
#[derive(Debug)]
192-
struct ScriptSource<'s> {
192+
pub struct ScriptSource<'s> {
193193
shebang: Option<&'s str>,
194194
info: Option<&'s str>,
195195
frontmatter: Option<&'s str>,
196196
content: &'s str,
197197
}
198198

199199
impl<'s> ScriptSource<'s> {
200-
fn parse(input: &'s str) -> CargoResult<Self> {
200+
pub fn parse(input: &'s str) -> CargoResult<Self> {
201201
let mut source = Self {
202202
shebang: None,
203203
info: None,
@@ -280,19 +280,19 @@ impl<'s> ScriptSource<'s> {
280280
Ok(source)
281281
}
282282

283-
fn shebang(&self) -> Option<&'s str> {
283+
pub fn shebang(&self) -> Option<&'s str> {
284284
self.shebang
285285
}
286286

287-
fn info(&self) -> Option<&'s str> {
287+
pub fn info(&self) -> Option<&'s str> {
288288
self.info
289289
}
290290

291-
fn frontmatter(&self) -> Option<&'s str> {
291+
pub fn frontmatter(&self) -> Option<&'s str> {
292292
self.frontmatter
293293
}
294294

295-
fn content(&self) -> &'s str {
295+
pub fn content(&self) -> &'s str {
296296
self.content
297297
}
298298
}

src/cargo/util/toml/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ mod targets;
3939

4040
use self::targets::to_targets;
4141

42+
pub use embedded::ScriptSource;
43+
4244
/// See also `bin/cargo/commands/run.rs`s `is_manifest_command`
4345
pub fn is_embedded(path: &Path) -> bool {
4446
let ext = path.extension();

0 commit comments

Comments
 (0)