Skip to content

Commit ce04810

Browse files
authored
Re-export sub-dependencies of exposed types (#39)
* Reorganize imports Separates private/public and groups use/mod. * Re-export sub-dependencies of exposed types The `fun_run` feature exposes the trait `CommandWithName` and the type `fun_run::CmdError`. If you try to use these with a different version of the `fun_run` crate you'll get an error. It can be difficult to debug as demonstrated in rust-lang/cargo#15591. This [blog suggested an easy fix](https://lobste.rs/s/iuvb8a/designing_error_types_rust_libraries): re-export any types your crate is using so your end users can depend on a unified version. It doesn't entirely scale if the end user has N crates with N different versions of `fun_run`, but it at least makes it better for the 1:1 case.
1 parent fbfa7b3 commit ce04810

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- Change: Result of `global::sub_start_timer(...).done()` is no longer "must use". This means it no longer needs `let _ =` for clippy. (https://github.com/heroku-buildpacks/bullet_stream/pull/38)
6+
- Add: The `fun_run` library is re-exported when `feature = "fun_run"` is enabled (on by default). This is because our crate exposes types from `fun_run` in the form of an error result `fun_run::CmdError`, now someone can use that feature and that type via re-export and guarantee it's the same version. (https://github.com/heroku-buildpacks/bullet_stream/pull/39)
67

78
## v0.8.0 - 2024/04/24
89

src/lib.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
#![doc = include_str!("../README.md")]
2-
32
use crate::util::ParagraphInspectWrite;
43
use crate::write::line_mapped;
4+
use global::GlobalWriter;
55
use std::fmt::Debug;
66
use std::io::Write;
77
use std::time::Instant;
8+
use style::CMD_INDENT;
9+
use util::TrailingParagraph;
10+
11+
pub use ansi_escape::strip_ansi;
12+
#[cfg(feature = "fun_run")]
13+
pub use fun_run;
814

915
mod ansi_escape;
1016
mod background_printer;
1117
mod duration_format;
12-
pub mod global;
13-
pub mod style;
1418
mod util;
1519
mod write;
16-
pub use ansi_escape::strip_ansi;
17-
use global::GlobalWriter;
18-
use style::CMD_INDENT;
19-
use util::TrailingParagraph;
20+
21+
pub mod global;
22+
pub mod style;
2023

2124
/// Use [`Print`] to output structured text as a buildpack/script executes. The output
2225
/// is intended to be read by the application user.

0 commit comments

Comments
 (0)