forked from cachix/devenv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a small example of how to turn the devenv binary into both a library and a binary. The reason this works is that the devenv/Cargo.toml file would allow you to specify one or more binaries, and only a single library. However, because we are using the default values for everything, we do not need to explicitly define these sections. The library entry point will be devenv/src/lib.rs. In the lib.rs file, we specify that we also want to use the log module. So we define and export this module. So now anything that imports the devenv package can just use devenv::log::* in order to access the pieces defined inside of that module. There is a problem including the command module since main.rs defines an App struct, and then the command module defines an implementation of that struct. The problem here being that lib.rs does not define the App struct, so when the command module has use crate::App, it is not defined as it is in the case of the devenv binary.
- Loading branch information
Showing
9 changed files
with
9 additions
and
32 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,4 @@ resolver = "2" | |
members = [ | ||
"devenv", | ||
"devenv-run-tests", | ||
"devenv_core", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,5 +28,4 @@ which = "6.0.0" | |
whoami = "1.5.1" | ||
xdg = "2.5.2" | ||
|
||
devenv_core = { path = "../devenv_core" } | ||
schemars = "0.8.16" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod log; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters