-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
git_testament!(…)
generate const
This way the testament can be used in `const fn`.
- Loading branch information
Showing
2 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use git_testament::{git_testament, git_testament_macros}; | ||
|
||
git_testament!(TESTAMENT); | ||
|
||
git_testament_macros!(TESTAMENT); | ||
|
||
const TESTAMENT_BRANCH_NAME_OR_DEFAULT: &str = { | ||
match TESTAMENT.branch_name { | ||
Some(branch_name) => branch_name, | ||
None => "main", | ||
} | ||
}; | ||
|
||
const MACROS_BRANCH_NAME_OR_DEFAULT: &str = { | ||
match TESTAMENT_branch!() { | ||
Some(branch_name) => branch_name, | ||
None => "main", | ||
} | ||
}; | ||
|
||
#[test] | ||
fn it_works() { | ||
assert_eq!(TESTAMENT_BRANCH_NAME_OR_DEFAULT, MACROS_BRANCH_NAME_OR_DEFAULT); | ||
} |