Rust官網於昨天2020年最後一天發布了新版本1.49以告別跌宕起伏的2020年,值得注意的是,這個廣受歡迎的程式語言的最新版本正在提升對64位的ARM Linux的支持狀態。
Rust 1.49已將其對64位ARM Linux的支持提升為Tier-1目標,這是最高級別的支持保證,與Rust的x86_64支持類似。
Rust長期以來在64位ARM Linux上運行良好,但現在被認為在ARM Linux上運行極佳,並被置於最高級別支持處理,這也使64位ARM Linux成為第一個達到一級標準支持的非x86項目。
Rust 1.49還將其64位ARM macOS和64位ARM Windows的支持從第3級升級到第2級。在第2級中,存在預構建的二進位文件,可以保障代碼的構建,但是存在更大的bug風險。這對於蘋果最近高歌猛進推出的自研M1晶片產品及其自建Apple Silicon體系設備的普及來說,不啻是個好消息。
Rust是一種程式語言,它使每個人都可以構建可靠且高效的軟體。Rust使用rustup工具安裝和管理。Rust具有為期六周的快速發布過程,並且支持Windows、MacOS、Linux或其他類Unix的作業系統等各平臺。rustup在Rust支持的每個平臺上以一致的方式管理這些構建,支持從Beta到release各分支安裝Rust,並支持交叉編譯。
如果您通過rustup安裝了Rust的早期版本,則升級Rust 1.49.0的過程非常簡單,僅需要執行下面命令:
rustup update stable
如果您未安裝過Rust,在Linux等非Windows平臺也可以使用下面命令快速安裝:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Rust 1.49還增強了其測試框架捕獲線程中的輸出。Rust的內置測試框架沒有包含太多功能,但這並不意味著它無法得到改進!我們來看一下像這樣的測試:
#[test]
fn thready_pass() {
println!("fee");
std::thread::spawn(|| {
println!("fie");
println!("foe");
})
.join()
.unwrap();
println!("fum");
}
在Rust 1.49.0之前版本,運行此測試後,將輸出:
? cargo +1.48.0 test
Compiling threadtest v0.1.0 (C:\threadtest)
Finished test [unoptimized + debuginfo] target(s) in 0.38s
Running target\debug\deps\threadtest-02f42ffd9836cae5.exe
running 1 test
fie
foe
test thready_pass ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Doc-tests threadtest
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
從上面結果中,您可以看到其列印了線程的輸出,該輸出混合顯示了測試框架本身的輸出。
也許您會問,每個println的輸出難道不能實現得更好麼?比如像上面測試代碼中println!("fum")那樣輸出列印「fum」這樣清晰明了?
沒錯,Rust 1.49.0實現了您的這個預期,在這版本中它將打出輸出:
? cargo test
Compiling threadtest v0.1.0 (C:\threadtest)
Finished test [unoptimized + debuginfo] target(s) in 0.52s
Running target\debug\deps\threadtest-40aabfaa345584be.exe
running 1 test
test thready_pass ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Doc-tests threadtest
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
您也許會說,這不是逗我麼?這有啥區別?看起來沒兩樣啊!
請不要擔心,如果測試失敗,您將會看到所有輸出。您只需要在上面測試代碼末尾添加「panic!」,您將看到詳細的錯誤信息:
? cargo test
Compiling threadtest v0.1.0 (C:\threadtest)
Finished test [unoptimized + debuginfo] target(s) in 0.52s
Running target\debug\deps\threadtest-40aabfaa345584be.exe
running 1 test
test thready_pass ... FAILED
failures:
---- thready_pass stdout ----
fee
fie
foe
fum
thread 'thready_pass' panicked at 'explicit panic', src\lib.rs:11:5
具體來說,在新版本中,測試運行程序將確保捕獲所有輸出,並在測試報錯時保存提供這些輸出信息。
特別聲明:以上內容(如有圖片或視頻亦包括在內)為自媒體平臺「網易號」用戶上傳並發布,本平臺僅提供信息存儲服務。
Notice: The content above (including the pictures and videos if any) is uploaded and posted by a user of NetEase Hao, which is a social media platform and only provides information storage services.