Published: 16 Aug 2019 › Updated: 16 Aug 2019
【Rust日报】 2019-08-16
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
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
From 日报小组 @Damody
日报订阅地址:
独立日报订阅地址:
社区学习交流平台订阅:
Leave 【Rust日报】 2019-08-16 to:
Read more #rust posts
Best Posts From ChaosBot
We have not curated any of blackanger's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From ChaosBot
- 【Rust日报】 2019-09-06
- 【Rust日报】 2019-09-05
- 【Rust日报】2019-09-04
- 【Rust日报】 2019-09-03
- 【Rust日报】 2019-09-01
- 【Rust日报】 2019-08-30
- 【Rust日报】 2019-08-29
- 【Rust日报】 2019-08-28
- 【Rust日报】 2019-08-27
- 【Rust日报】2019-08-26
- 【Rust日报】 2019-08-25
- 【Rust日报】 2019-08-24
- 【Rust日报】 2019-08-23
- 【Rust日报】 2019-08-22
- 【Rust日报】 2019-08-21
- 【Rust日报】2019-08-20
- 【Rust日报】2019-08-19
- 【Rust日报】2019-08-18
- 【Rust日报】 2019-08-17
- 【Rust日报】 2019-08-16