随笔分类 - Rust
摘要:环境 Time 2021-12-07 Rust 1.57.0 serde 1.0.130 serde_json 1.0.72 概念 参考:https://serde.rs/ignored-any.html 示例 main.rs use std::fmt; use std::marker::Phant
阅读全文
摘要:环境 Time 2021-12-06 Rust 1.57.0 serde 1.0.130 serde_json 1.0.72 概念 参考:https://serde.rs/attr-bound.html 示例 如果类型不同,会出现错误:"invalid type: string xxxx , exp
阅读全文
摘要:环境 Time 2021-12-02 VSCode 1.61.2 Rust 1.56.1 Serde 1.0.72 概念 参考:https://docs.serde.rs/serde_json/index.html#operating-on-untyped-json-values 示例 转换出来的
阅读全文
摘要:环境 Time 2021-12-02 VSCode 1.61.2 Rust 1.56.1 Serde 1.0.72 概念 参考:https://docs.serde.rs/serde_json/index.html#parsing-json-as-strongly-typed-data-struct
阅读全文
摘要:环境 Time 2021-12-02 VSCode 1.61.2 Rust 1.56.1 Serde 1.0.72 概念 参考:https://docs.serde.rs/serde_json/index.html#serde-json 示例 Cargo.toml [package] edition
阅读全文
摘要:环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/book/ch20-03-graceful-shutdown-and-cleanup.html 示例 main.rs use std::fs; use std::i
阅读全文
摘要:环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/book/ch20-01-single-threaded.html 示例 main.rs use std::fs; use std::io::Read; use s
阅读全文
摘要:环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/book/ch20-02-multithreaded.html 示例 main.rs use std::fs; use std::io::Read; use std
阅读全文
摘要:环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/book/ch12-00-an-io-project.html 示例 main.rs use std::{env, process}; fn main() { le
阅读全文
摘要:环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/book/ch02-00-guessing-game-tutorial.html 示例 main.rs use std::{cmp::Ordering, io::s
阅读全文
摘要:环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/compatibility/raw_identifiers.html 示例 原始标识符可以避免由于新增加关键字导致的不兼容问题,使用
阅读全文
摘要:环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/rust-by-example/std/str.html 示例 转义 fn main() { let byte_escape = "I'm writing \x52\x75\x7
阅读全文
摘要:环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/rust-by-example/std/str.html 示例 在字符串前加上一个 b 来表示。 main.rs use std::str; fn main() { let by
阅读全文
摘要:环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/testing/dev_dependencies.html 示例 main.rs #[cfg(test)] #[macro_use]
阅读全文
摘要:环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/unsafe.html 示例 原始指针 fn main() { let raw_p: *const u32 = &10; unsaf
阅读全文
摘要:环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/testing/integration_testing.html 示例 Cargo.toml [package] name = "a
阅读全文
摘要:环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/testing/doc_testing.html 示例 main.rs /// /// ``` /// # fn foo() {}
阅读全文
摘要:环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/testing/unit_testing.html 示例 测试相等 pub fn add(a: i32, b: i32) -> i3
阅读全文
摘要:环境 Rust 1.56.1 VSCode 1.61.2 Windows 7 mingw64 7.3.0 概念 参考:https://stackoverflow.com/questions/40833078/how-do-i-specify-the-linker-path-in-rust 示例 Ca
阅读全文
摘要:环境 Rust 1.56.1 VSCode 1.61.2 概念 参考:https://doc.rust-lang.org/stable/rust-by-example/std_misc/fs.html 示例 创建文件夹 use std::fs; fn main() { println!("`mkdi
阅读全文