前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【Rust 日报】2024-03-31 Helix新版本发布

【Rust 日报】2024-03-31 Helix新版本发布

作者头像
MikeLoveRust
发布2024-04-02 12:22:27
890
发布2024-04-02 12:22:27
举报

[new version] Helix 24.03

Helix是一个Rust写的编辑器,本次更新如下。

  • AWP一样的跳转。
  • 块注释。
  • 改进了多语言文档的解析。
  • 内部改进:事件系统、用regex-cursor替换了regex。

GitHub: https://github.com/helix-editor/helix

[new lib] profi

profi是一个支持单线程/多线程细粒度的性能分析器。

使用示例:

代码语言:javascript
复制
// 基本方法
use profi::{prof, print_on_exit};

fn main() {
 // Prints the timings to stdout when the program exits
 // Always put at the top of the main function to ensure it's dropped last
 //
 // An implicit `main` guard is created to profile the whole application
 print_on_exit!();

 // Sleep for a bit to simulate some work
 std::thread::sleep(std::time::Duration::from_millis(200));
}

// 循环
use profi::{prof, print_on_exit};

fn main() {
  print_on_exit!();

  for _ in 0..100 {
      prof!(iteration);
      std::thread::sleep(std::time::Duration::from_millis(10));
  }
}

// 多线程
use profi::{print_on_exit, prof_guard};

fn do_work(i: usize) {
    // Need to bind it to a variable to ensure it isn't dropped before sleeping
    let _guard = if i < 6 {
        prof_guard!("6 first")
    } else {
        prof_guard!("4 last")
    };
    std::thread::sleep(std::time::Duration::from_millis(10));
    // The guard goes out of scope here
}

fn main() {
    print_on_exit!();
    
    // Spawn 10 threads
    std::thread::scope(|s| {
        for i in 0..10 {
            s.spawn(move || {
                do_work(i);
            });
        }
    });
}

GitHub: https://github.com/lyonsyonii/profi

[new lib] terrors

terrors是一个Rust处理错误的库,设计原则包括:

  • 错误类型应精确。terrors通过精确设置可能的错误集来解决这个问题。
  • 错误处理应遵循单一责任原则。
  • 没有宏。

简单使用示例:

代码语言:javascript
复制
use terrors::OneOf;

let one_of_3: OneOf<(String, u32, Vec<u8>)> = OneOf::new(5);

let narrowed_res: Result<u32, OneOf<(String, Vec<u8>)>> =
    one_of_3.narrow();

assert_eq!(5, narrowed_res.unwrap());

GitHub: https://github.com/komora-io/terrors

Rust学习资源

有网友推荐一个YouTube的学习视频,一共37个视频,感兴趣的读者不妨查阅。

链接: https://www.youtube.com/watch?v=lTjGt17bQ3k&list=PLDbRgZ0OOEpUkWDGqp91ODn0dk7LPBAUL&index=1

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2024-04-01,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Rust语言学习交流 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • [new version] Helix 24.03
  • [new lib] profi
  • [new lib] terrors
  • Rust学习资源
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档