-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(libmake): ♻️ added new utility_macros and simplifying interface.rs
- Loading branch information
1 parent
c894cbf
commit 1d82384
Showing
3 changed files
with
60 additions
and
61 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
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,32 @@ | ||
// Copyright notice and licensing information. | ||
// These lines indicate the copyright of the software and its licensing terms. | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT indicates dual licensing under Apache 2.0 or MIT licenses. | ||
// Copyright © 2024 LibMake. All rights reserved. | ||
|
||
/// Replaces placeholders in a given line with corresponding values from the provided parameters. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `line` - The line containing placeholders to be replaced. | ||
/// * `params` - The parameters containing values to replace the placeholders. | ||
/// * `$($field:ident),+` - Identifiers representing the fields in `params` to be replaced. | ||
/// | ||
/// # Returns | ||
/// | ||
/// The line with placeholders replaced by their corresponding values. | ||
/// | ||
#[macro_export] | ||
macro_rules! macro_replace_placeholder { | ||
($line:expr, $params:expr, $($field:ident),+) => { | ||
{ | ||
let mut line = $line; | ||
$( | ||
line = line.replace( | ||
concat!("{", stringify!($field), "}"), | ||
&$params.$field.as_deref().unwrap_or(""), | ||
); | ||
)+ | ||
line | ||
} | ||
}; | ||
} |