您当前的位置: 首页 >  rust

mutourend

暂无认证

  • 2浏览

    0关注

    661博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Rust std::stringify宏使用示例

mutourend 发布时间:2019-09-18 15:56:54 ,浏览量:2

macro_rules! stringify {
    ($($t:tt)*) => { ... };
}

作用是将其参数直接转换为字符串描述,类型为&'static str。适合用于描述数学公式变量名等。

举例:

let one_plus_one = stringify!(1 + 1);
assert_eq!(one_plus_one, "1 + 1");

参考资料: [1] https://doc.rust-lang.org/std/macro.stringify.html

关注
打赏
1664532908
查看更多评论
立即登录/注册

微信扫码登录

0.0563s