add macro util to determine if cargo build or check/clippy.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
43b0bb6a5e
commit
c40d20cb95
1 changed files with 10 additions and 0 deletions
|
@ -2,6 +2,16 @@ use syn::{parse_str, Expr, Generics, Lit, Meta};
|
||||||
|
|
||||||
use crate::Result;
|
use crate::Result;
|
||||||
|
|
||||||
|
pub(crate) fn is_cargo_build() -> bool {
|
||||||
|
std::env::args()
|
||||||
|
.find(|flag| flag.starts_with("--emit"))
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|flag| flag.split_once('='))
|
||||||
|
.map(|val| val.1.split(','))
|
||||||
|
.and_then(|mut vals| vals.find(|elem| *elem == "link"))
|
||||||
|
.is_some()
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn get_named_generics(args: &[Meta], name: &str) -> Result<Generics> {
|
pub(crate) fn get_named_generics(args: &[Meta], name: &str) -> Result<Generics> {
|
||||||
const DEFAULT: &str = "<>";
|
const DEFAULT: &str = "<>";
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue