1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#[macro_export]
macro_rules! s {
    ($e:literal) => {$e.to_owned() as String};
}

#[macro_export]
macro_rules! string {
    ($e:literal) => {$e.to_owned() as String};
}

#[cfg(test)]
mod test {
    // enforces same type
    fn strict_equals<T: std::cmp::PartialEq>(a: T, b: T) -> bool {
        return a == b;
    }

    #[test]
    fn same_type_and_value() {
        assert!(strict_equals(s!("abcd"), "abcd".to_owned()));
        assert!(strict_equals(string!("abcd"), "abcd".to_owned()));
        println!("OK");
    }
}