摘要:
title: rust atoi date: 2021-12-03 21:06:44 tags: rust标准库里没有atoi。要将字符串转为整数,可以用parse: fn main() { let s = "23333"; let x: usize = s.parse().unwrap(); pr 阅读全文
posted @ 2024-09-28 13:45
寻找繁星
阅读(35)
评论(0)
推荐(0)
摘要:
title: Rust vector reduce size date: 2022-08-26 22:11:13 tags: resize requires a default value: fn resize(&mut self, new_len: usize, value: T) While t 阅读全文
posted @ 2024-09-28 13:45
寻找繁星
阅读(30)
评论(0)
推荐(0)
摘要:
title: rust二分搜索 date: 2021-10-06 17:38:25 如果要二分搜索某个特定值,可以用binary_search: https://doc.rust-lang.org/stable/std/primitive.slice.html#method.binary_searc 阅读全文
posted @ 2024-09-28 13:45
寻找繁星
阅读(101)
评论(0)
推荐(0)
摘要:
title: rust交换数组中的两个元素 date: 2021-10-20 21:52:18 不可以直接用std::mem::swap,因为这个函数需要拿两个可变引用,但是不可以同时拿两个这个数组的可变引用。 所以要么手写: let tmp = a[i]; a[i] = a[j]; a[j] = 阅读全文
posted @ 2024-09-28 13:45
寻找繁星
阅读(87)
评论(0)
推荐(0)
摘要:
title: rust打印变量类型 date: 2021-09-29 20:30:45 可以试试std::any::type_name。注意,这个是unstable的。 use std::collections::HashSet; fn print_type_of<T>(_: &T) { print 阅读全文
posted @ 2024-09-28 13:45
寻找繁星
阅读(61)
评论(0)
推荐(0)
摘要:
title: rust翻转数组 date: 2021-10-06 18:23:49 https://doc.rust-lang.org/stable/std/primitive.slice.html#method.reverse 阅读全文
posted @ 2024-09-28 13:45
寻找繁星
阅读(24)
评论(0)
推荐(0)
摘要:
title: rust查看标准库源码 date: 2020-08-17 10:19:18 tags: 标准库文档:https://docs.rs/std 点击API文档的src即可看到。 阅读全文
posted @ 2024-09-28 13:45
寻找繁星
阅读(53)
评论(0)
推荐(0)
摘要:
title: rust运行shell命令并获取输出 date: 2021-08-17 17:53:28 use std::io::{BufReader, BufRead}; use std::process::{self, Command, Stdio}; fn main() { ls(); ps( 阅读全文
posted @ 2024-09-28 13:45
寻找繁星
阅读(294)
评论(0)
推荐(0)
摘要:
title: git同步空文件夹 date: 2019-11-29 23:36:31 参考链接:https://www.iteye.com/blog/hbiao68-2103286 在这个文件夹中建立一个空的.gitignore文件就好了(可以用touch命令) 如果顶层的.gitignore中没有 阅读全文
posted @ 2024-09-28 13:44
寻找繁星
阅读(32)
评论(0)
推荐(0)
摘要:
title: git回退指定个commit date: 2022-09-19 19:28:05 tags: 回退3个commit: git reset --hard HEAD~3 来源:https://git-scm.com/docs/git-reset 阅读全文
posted @ 2024-09-28 13:44
寻找繁星
阅读(41)
评论(0)
推荐(0)

浙公网安备 33010602011771号