• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
返回主页

寻找繁星

Synced with https://seekstar.github.io

  • 博客园
  • 首页
  • 新随笔
  • 联系
  • 订阅
  • 管理

rust格式控制

官方教程:https://doc.rust-lang.org/std/fmt/

注意,标准库里的格式控制字符串必须是字面量:
https://www.reddit.com/r/rust/comments/48jzw0/formatting_with_a_static_string_literal/
https://stackoverflow.com/questions/46788199/how-to-create-a-constant-string-literal-in-rust
https://stackoverflow.com/questions/32572486/how-can-i-use-a-dynamic-format-string-with-the-format-macro

如果想要动态的格式控制字符串,可以试试strfmt:
https://github.com/vitiral/strfmt

固定宽度左边补零

rust print固定宽度左边补零

浮点数打印时忽略浮点误差

rust不支持%g:

Pretty print isn't pretty for floats

https://github.com/sampsyo/bril/pull/218

不过可以用crate gpoint实现:https://crates.io/crates/gpoint

posted @ 2024-09-28 14:16  寻找繁星  阅读(7)  评论(0)    收藏  举报
刷新页面返回顶部

公告

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3