Finished refactoring

This commit is contained in:
elvis
2025-08-24 03:35:32 +02:00
parent 3a4c4d43c2
commit 9a80044a89
11 changed files with 511 additions and 301 deletions

View File

@ -1,7 +1,8 @@
//! Module for translation and keeping track of strings.
use std::collections::HashMap;
use serde::{Serialize, Deserialize};
use std::collections::HashMap;
use std::fmt;
/// precision for printing frequencies
pub static PRECISION: &usize = &2;
@ -102,51 +103,3 @@ impl<'a, T> Formatter<'a, T> {
}
use super::{
structure::{
RSassert
},
};
use std::fmt;
macro_rules! translator_structure {
($name:ident, $type:ty, $dataname:ident, $print_func:ident) => {
#[derive(Clone, Debug)]
#[allow(dead_code)]
pub struct $name<'a> {
translator: &'a Translator,
$dataname: &'a $type,
}
#[allow(dead_code)]
impl <'a>$name<'a> {
pub fn from(translator: &'a Translator, $dataname: &'a $type) -> Self {
$name { translator, $dataname }
}
}
impl<'a> fmt::Display for $name<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
$print_func(f, self.translator, self.$dataname)
}
}
};
}
// RSassert
#[allow(unused_variables)]
fn print_assert(
f: &mut fmt::Formatter,
translator: &Translator,
assert: &RSassert
) -> fmt::Result {
todo!()
}
translator_structure!(RSassertDisplay, RSassert, assert, print_assert);