随笔分类 -  Rust

摘要:原理 通过宏实现,代码来自 macro-log: use proc_macro::TokenStream; use quote::quote; use syn::LitStr; pub fn read_dir(args: TokenStream) -> TokenStream { let path 阅读全文
posted @ 2023-10-13 17:40 develon 阅读(177) 评论(0) 推荐(0) 编辑
摘要:# async 观察代码: ``` async fn dd(a: i32) -> i32 { dbg!(a); 2 * a } ``` 异步方法内可以执行await,很显然上面的代码等价于下面两种形式: ``` async fn dd(a: i32) -> i32 { dbg!(a); async 阅读全文
posted @ 2023-07-01 18:25 develon 阅读(51) 评论(0) 推荐(0) 编辑
摘要:# 资料 Rust 程序设计语言 Book:https://doc.rust-lang.org/book/ Rust Book本地:`rustup docs --book` Rust 程序设计语言 简体中文版:https://kaisery.github.io/trpl-zh-cn/ Rust Bo 阅读全文
posted @ 2023-05-19 17:06 develon 阅读(47) 评论(0) 推荐(0) 编辑
摘要:# #[tokio::test] 运行时 `#[tokio::test]` 运行时和 `#[tokio::main]` 的默认值是不一样的,前者默认单线程,后者默认多线程: > The default test runtime is single-threaded. 所以有的时候运行和测试的结果可能 阅读全文
posted @ 2023-05-19 16:14 develon 阅读(485) 评论(0) 推荐(0) 编辑
摘要:# (&mut Future).await 直接执行 `join_handle.await` 会消费 JoinHandle ,通过 `(&mut join_handle).await` 不消费 JoinHandle ,参考:https://github.com/tokio-rs/tokio/disc 阅读全文
posted @ 2023-05-15 17:12 develon 阅读(126) 评论(2) 推荐(0) 编辑
摘要:添加target:wasm32-unknown-unknown rustup target add wasm32-unknown-unknown info: downloading component 'rust-std' for 'wasm32-unknown-unknown' info: ins 阅读全文
posted @ 2023-04-25 11:45 develon 阅读(119) 评论(0) 推荐(0) 编辑
摘要:尝试修改项目 Cargo.toml [dependencies] openssl = { version = "0.10", features = ["vendored"] } https://github.com/sfackler/rust-openssl/issues/1021 无效,因为是执行 阅读全文
posted @ 2023-04-25 11:29 develon 阅读(134) 评论(0) 推荐(0) 编辑
摘要:问题描述 构建时间较长,文件较大 Finished dev [unoptimized + debuginfo] target(s) in 24.36s real 0m24.724s user 0m10.158s sys 0m2.687s ubuntu@VM-12-10-ubuntu:~/test/t 阅读全文
posted @ 2022-11-11 16:34 develon 阅读(157) 评论(0) 推荐(0) 编辑
摘要:Cargo.toml [package] name = "static_link" version = "0.1.0" authors = ["develon <develon@qq.com>"] edition = "2018" build = "build.rs" # See more keys 阅读全文
posted @ 2022-08-29 17:06 develon 阅读(118) 评论(0) 推荐(0) 编辑
摘要:git-fetch-with-cli [net] git-fetch-with-cli = true 查询命令行: wmic:root\cli>process where caption="git.exe" get ExecutablePath, caption, CommandLine Capti 阅读全文
posted @ 2022-07-25 16:59 develon 阅读(2332) 评论(1) 推荐(0) 编辑
摘要:# 添加编译目标 首先明确一下,Rust 有个平台支持等级的概念,处于等级1的平台可以使用 `rustup default [stable-x86_64-pc-windows-msvc]` 设置为主机平台,其它等级的只能使用以下方式设置为编译目标: ``` rustup target add aar 阅读全文
posted @ 2022-07-10 23:10 develon 阅读(4479) 评论(7) 推荐(0) 编辑
摘要:bincode fn bin<T>(p: &T) { bin2(p, std::mem::size_of_val(p) as i8); } fn bin2<T>(p: *const T, le: i8) { let p = p as *const u8; println!("show {:p}, c 阅读全文
posted @ 2022-03-15 17:55 develon 阅读(295) 评论(1) 推荐(0) 编辑
摘要:研究性代码 alert('doo'); #[no_mangle] // extern "C" fn using(f: extern "C" fn()) { extern "C" fn using(f: *const u8) { let a = (&f) as *const _ as *const f 阅读全文
posted @ 2022-03-11 18:31 develon 阅读(1436) 评论(0) 推荐(0) 编辑
摘要:使用 cmake 的局限性 .lib 合并问题 cmake 不会将多个 .lib 合并, 因此可能需要使用 add_custom_command 命令手动使用 MSVC 工具 lib.exe 来创建最终具有 C ABI 的 .lib 静态库文件供Rust调用. set(Target "output" 阅读全文
posted @ 2022-03-07 22:53 develon 阅读(2006) 评论(1) 推荐(0) 编辑
摘要:设置cfg选项以有条件地进行编译 RUSTFLAGS='--cfg buffersize="32"' cargo build see 关于rust - 如何设置cfg选项以有条件地进行编译?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com 阅读全文
posted @ 2021-07-27 10:41 develon 阅读(129) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示