ITPub博客

首页 > 数据库 > 数据库开发技术 > 【Rust日报】 2019-08-16:Rust 1.37.0 稳定版已发布

【Rust日报】 2019-08-16:Rust 1.37.0 稳定版已发布

原创 数据库开发技术 作者:Rust语言中文社区 时间:2019-08-16 22:59:26 0 删除 编辑


Rust 1.37.0 稳定版已发布

  • 現在可以使用 type 製作別名

type ByteOption = Option<u8>;

fn increment_or_zero(x: ByteOption) -> u8 {
match x {
ByteOption::Some(y) => y + 1,
ByteOption::None => 0,
}
}
  • 而在實作(实现)函數中 Self 可以當成目前結構的別名

impl Coin {
fn value_in_cents(&self) -> u8 {
match self {
Self::Penny => 1,
Self::Nickel => 5,
Self::Dime => 10,
Self::Quarter => 25,
}
}
}
  • 現在可以有匿名的變數在巨集(宏)中

/// Type size assertion where the first parameter
/// is a type and the second is the expected size.
#[macro_export]
macro_rules! static_assert_size {
($ty:ty, $size:expr) => {
const _: [(); $size] = [(); ::std::mem::size_of::<$ty>()];
// ^ Note the underscore here.
}
}

static_assert_size!(Option<Box<String>>, 8); // 1.
static_assert_size!(usize, 8); // 2.

現在程式可以根據實際的執行情況最佳化編譯,神奇的功能!

首先編譯時 rustc 加入 -C profile-generate

然後執行這個程式跑一跑你的測試資料後會產生記錄檔

再來第二次編譯 rustc 加入 -C profile-use

會根據你剛剛跑的結果來最佳化編譯

  • 現在將編譯出執行檔做為預設(缺省)行為

如果你沒打 --bin 也可以編

  • enum 也可以對齊了

#[repr(align(16))]
enum Align16 {
Foo { foo: u32 },
Bar { bar: u32 },
}
  • 下面的函數穩定了

BufReader::buffer and BufWriter::buffer
Cell::from_mut
Cell::as_slice_of_cells
DoubleEndedIterator::nth_back
Option::xor
[{i,u}{8,16,32,64,128,size}::reverse_bits] and Wrapping::reverse_bits
slice::copy_within

read more

Grand Star v0.6.0

任天堂也用Rust了。這是任天堂的 rust tool chain跟庫的集合

這些庫還不成熟,還在開發中,非常需要有時間的人幫忙開發

歡迎大家的加入

  • reddit 讨论

  • GitHub Org: https://github.com/rust-wii/

Yew v0.8

  • 現在html <div class="marker" /> 可以使用/>來對tag做描述,

  • 現在 SVG 命名空間可以使用

  • Properties 可以被整合編譯

詳細請看 changelog

read more


From 日报小组 @Damody

日报订阅地址:

独立日报订阅地址:

  • Telgram Channel

  • 阿里云语雀订阅

  • Steemit

  • GitHub

社区学习交流平台订阅:

  • Rust.cc论坛: 支持rss

  • Rust Force: 支持rss

  • 微信公众号:Rust语言学习交流

原文作者:Rust语言中文社区;如有侵权,请联系管理员删除。

请登录后发表评论 登录
全部评论

注册时间:2020-06-11

  • 博文量
    1769
  • 访问量
    718505