Skip to content

Commit e447448

Browse files
committed
calc: Use compile-time macro env!
1 parent 6f6fdbf commit e447448

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

calc/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ edition.workspace = true
77
rust-version.workspace = true
88

99
[dependencies]
10-
plib = { path = "../plib" }
1110
gettext-rs.workspace = true
1211
regex.workspace = true
1312
clap.workspace = true
@@ -17,6 +16,9 @@ lazy_static = "1.4"
1716
bigdecimal = "0.4"
1817
rustyline = { version = "14.0", default-features = false }
1918

19+
[dev-dependencies]
20+
plib = { path = "../plib" }
21+
2022
[lints]
2123
workspace = true
2224

calc/bc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use bc_util::{
1616
use clap::Parser;
1717

1818
use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory};
19-
use plib::PROJECT_NAME;
2019
use rustyline::{error::ReadlineError, DefaultEditor, Result};
2120

2221
mod bc_util;
@@ -45,10 +44,11 @@ fn print_output_or_error(result: ExecutionResult<String>) {
4544

4645
fn main() -> Result<()> {
4746
setlocale(LocaleCategory::LcAll, "");
48-
textdomain(PROJECT_NAME)?;
49-
bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?;
47+
textdomain(env!("PROJECT_NAME"))?;
48+
bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?;
5049

5150
let args = Args::parse();
51+
5252
let mut interpreter = Interpreter::default();
5353

5454
if args.define_math_functions {

calc/expr.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
//
99

1010
use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory};
11-
use plib::PROJECT_NAME;
1211
use regex::Regex;
1312

1413
#[derive(Clone, Debug, PartialEq)]
@@ -370,10 +369,9 @@ fn eval_expression(tokens: &[Token]) -> Result<Token, &'static str> {
370369
}
371370

372371
fn main() -> Result<(), Box<dyn std::error::Error>> {
373-
// initialize translations
374372
setlocale(LocaleCategory::LcAll, "");
375-
textdomain(PROJECT_NAME)?;
376-
bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?;
373+
textdomain(env!("PROJECT_NAME"))?;
374+
bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?;
377375

378376
// tokenize and evaluate the expression
379377
let arg_tokens = tokenize();

calc/tests/bc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// SPDX-License-Identifier: MIT
88
//
99

10-
use plib::{run_test, TestPlan};
10+
use plib::testing::{run_test, TestPlan};
1111

1212
fn test_bc(program: &str, expected_output: &str) {
1313
run_test(TestPlan {

calc/tests/expr/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// SPDX-License-Identifier: MIT
88
//
99

10-
use plib::{run_test, TestPlan};
10+
use plib::testing::{run_test, TestPlan};
1111

1212
fn expr_test(args: &[&str], expected_output: &str) {
1313
let str_args: Vec<String> = args.iter().map(|s| String::from(*s)).collect();

0 commit comments

Comments
 (0)