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

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

内容简介: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! 宏不使用参数调用》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

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

An Introduction to Probability Theory and Its Applications

An Introduction to Probability Theory and Its Applications

William Feller / Wiley / 1991-1-1 / USD 120.00

Major changes in this edition include the substitution of probabilistic arguments for combinatorial artifices, and the addition of new sections on branching processes, Markov chains, and the De Moivre......一起来看看 《An Introduction to Probability Theory and Its Applications》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试