Rust 1.35.0,dbg! 宏不使用参数调用

栏目: 软件资讯 · 发布时间: 6年前

内容简介:Rust 1.35.0 稳定版发布了。 如果之前已经通过 rustup 安装了 Rust,那么可以通过以下方式获取 Rust 1.35.0: $ rustup update stable 或者直接从更新页面下载。 此版本的亮点包括: 分别为 Box<dyn FnOnce>、B...

Rust 1.35.0 稳定版发布了。

如果之前已经通过 rustup 安装了 Rust,那么可以通过以下方式获取 Rust 1.35.0:

$ rustup update stable

或者直接从更新页面下载。

此版本的亮点包括:

  • 分别为 Box<dyn FnOnce>、Box<dyn FnMut> 和 Box<dyn Fn> 实现了 FnOnce、FnMut 和 Fn 闭包 trait。
fn foo(x: Box<dyn Fn(u8) -> u8>) -> Vec<u8> {
    vec![1, 2, 3, 4].into_iter().map(x).collect()
}

 

fn foo(x: Box<dyn FnOnce()>) {
    x()
}
  • 现在可以将闭包强制转换为不安全的函数指针。
unsafe fn call_unsafe(func: unsafe fn()) {
    func()
}

pub fn main() {
    unsafe { call_unsafe(|| {}); }
}
  • Rust 1.32.0 中引入的 dbg! 宏现在可以不使用参数调用。
fn main() {
    let condition = true;

    if condition {
        dbg!();
    }
}
  • 许多标准库稳定。

详情查看发布说明:

https://blog.rust-lang.org/2019/05/23/Rust-1.35.0.html


以上所述就是小编给大家介绍的《Rust 1.35.0,dbg! 宏不使用参数调用》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Introduction to Tornado

Introduction to Tornado

Michael Dory、Adam Parrish、Brendan Berg / O'Reilly Media / 2012-3-28 / USD 23.99

Tornado is a scalable, non-blocking web server and web application framework written in Python. It is also light-weight to deploy, fun to write for, and incredibly powerful. Tornado was written with p......一起来看看 《Introduction to Tornado》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具