pu369com

上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 32 下一页

2021年9月10日

rust thread '<main>' has overflowed its stack in Rust

摘要: 在子线程中,写成这样就不提示溢出了 use std::thread; use std::time::Duration; fn main() { let handle = thread::Builder::new().stack_size(2 * 1024 * 1024 * 1024 ).spawn( 阅读全文

posted @ 2021-09-10 16:29 pu369com 阅读(359) 评论(0) 推荐(0) 编辑

2021年9月9日

Cargo 工作空间

摘要: 参考:https://www.cntofu.com/book/192/src/ch14-03-cargo-workspaces.md 要点: 1、在目录名为add的根目录(或者叫workspaces)下的Cargo.toml,称为顶级Cargo.toml 其中[workspace]字段指明了工作空间 阅读全文

posted @ 2021-09-09 17:17 pu369com 阅读(122) 评论(0) 推荐(0) 编辑

rust windows-rs 调用GetLogicalDriveStringsW显示硬盘目录

摘要: win10系统 Cargo.toml [dependencies] windows = "0.19" encoding = "0.2" [build-dependencies] windows = "0.19" main.rs mod bindings { windows::include_bind 阅读全文

posted @ 2021-09-09 11:21 pu369com 阅读(559) 评论(0) 推荐(0) 编辑

2021年9月7日

rust win32api EnumWindows

摘要: 1 Cargo.toml [package] name = "hellowinapi" version = "0.1.0" edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/carg 阅读全文

posted @ 2021-09-07 17:59 pu369com 阅读(518) 评论(0) 推荐(0) 编辑

RUST编写和调用DLL

摘要: 1 执行 cargo new hellolib --lib 创建库项目 修改 cargo.toml [lib] name = "myfirst_rust_dll" #生成dll的文件名 crate-type = ["dylib"] lib.rs #[no_mangle] pub extern fn 阅读全文

posted @ 2021-09-07 16:30 pu369com 阅读(7711) 评论(0) 推荐(0) 编辑

2021年9月4日

rust 高阶函数 (high order function)

摘要: 手机抄代码都费劲,一是用firefox登不上博客园,因为光标定位在密码框中时弹不出手机键盘,换uc好了。二是比如输入大括号时,手机总自做聪明地错误添加或删除成对的括号(这个可以修改输入法设置)。要感谢rust playground和uc,让我们在手机上也能调试代码。 所谓高阶函数,就是函数中可以传入 阅读全文

posted @ 2021-09-04 23:49 pu369com 阅读(253) 评论(0) 推荐(0) 编辑

2021年8月25日

Rust从&[u8] bytes中读取任意类型的整数(如i32, u32等多种类型)

摘要: 其实代码最后一行实现了同样功能,但可以用来学习trait和macro use std::convert::TryInto; pub trait ReadInteger<T> { fn from_le_bytes(data: &[u8]) -> T; fn from_be_bytes(data: &[ 阅读全文

posted @ 2021-08-25 16:04 pu369com 阅读(611) 评论(0) 推荐(0) 编辑

2021年8月24日

rust 裸指针

摘要: *const T和*mut T在Rust中被称为“裸指针” 可以绕过Rust的安全保障 有一些你需要记住的裸指针不同于其它指针的地方。它们是: 不能保证指向有效的内存,甚至不能保证是非空的(不像Box和&); 没有任何自动清除,不像Box,所以需要手动管理资源; 是普通旧式类型,也就是说,它不移动所 阅读全文

posted @ 2021-08-24 18:43 pu369com 阅读(633) 评论(0) 推荐(0) 编辑

rust 的奇葩点(.和..)语法小记

摘要: 1 (.)点运算符 看到类似语句: let s = "12345".split_terminator("").0; 编译器提示:error[E0616]: field `0` of struct `SplitTerminator` is private 原来被最后那个0给迷惑了,这个点就是 成员访问 阅读全文

posted @ 2021-08-24 18:02 pu369com 阅读(529) 评论(1) 推荐(0) 编辑

2021年8月22日

rust 大神crypto2的例子AES加解密

摘要: 我稍微改了一下,代码: extern crate crypto2; use crypto2::blockcipher::Aes128; fn main() { let key = [ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 阅读全文

posted @ 2021-08-22 09:09 pu369com 阅读(850) 评论(0) 推荐(0) 编辑

上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 32 下一页

导航