07 2022 档案

摘要:https://zhuanlan.zhihu.com/p/492292655 阅读全文
posted @ 2022-07-30 15:06 CrossPython 阅读(48) 评论(0) 推荐(0)
摘要:#[derive(Debug)] enum Unit{ INT(i32), STR(String), FLOAT(f32) } #[derive(Debug)] struct People{ name: String, elements: Vec<Unit> } impl IntoIterator 阅读全文
posted @ 2022-07-28 13:36 CrossPython 阅读(31) 评论(0) 推荐(0)
摘要:struct CountdownIterator(i32); impl Iterator for CountdownIterator { type Item = i32; fn next(&mut self) -> Option<Self::Item> { self.0 -= 1; if self. 阅读全文
posted @ 2022-07-28 12:26 CrossPython 阅读(24) 评论(0) 推荐(0)
摘要:use std::ptr; use std::fmt::{ Display, Formatter, Result }; pub struct Node { value: i32, next: *mut Node } impl Node { pub fn new(val: i32) -> Self { 阅读全文
posted @ 2022-07-28 11:52 CrossPython 阅读(31) 评论(0) 推荐(0)
摘要:通过迭代器提供的filter()和collect()方法。 let list2: Vec<_> = (1..=100).filter(|i| i%3 == 0).collect();assert_eq!(list1, list2); take(k)取前面k个元素。 迭代器调用take()后,迭代器的 阅读全文
posted @ 2022-07-28 10:39 CrossPython 阅读(69) 评论(0) 推荐(0)
摘要:use postgres::{Client, NoTls}; fn main(){ let mut client = Client::connect("host=localhost user=postgres password=postgres port=5433", NoTls).unwrap() 阅读全文
posted @ 2022-07-27 13:46 CrossPython 阅读(80) 评论(0) 推荐(0)
摘要:use std::fmt::{Debug, Display}; use std::any::TypeId; use std::any::Any; fn is_string<T: ?Sized + Any>(_s: &T) -> bool { TypeId::of::<String>() == Typ 阅读全文
posted @ 2022-07-25 22:01 CrossPython 阅读(28) 评论(0) 推荐(0)
摘要:mopa = 0.2 use mopa; use std::fmt::Debug; use std::fmt::Display; use std::any::TypeId; fn is_string<T: ?Sized + mopa::Any>(_s: &T) -> bool { TypeId::o 阅读全文
posted @ 2022-07-25 18:38 CrossPython 阅读(21) 评论(0) 推荐(0)
摘要:#[macro_use] extern crate mopa; struct Bear { // This might be a pretty fat bear. fatness: u16, } impl Bear { fn eat(&mut self, person: Box<dyn Person 阅读全文
posted @ 2022-07-25 18:28 CrossPython 阅读(27) 评论(0) 推荐(0)
摘要:downcast-rs = "1.2" // Can call macro via namespace since rust 1.30. use downcast_rs::Downcast; use std::fmt::Debug; // To create a trait with downcas 阅读全文
posted @ 2022-07-24 09:53 CrossPython 阅读(117) 评论(0) 推荐(0)
摘要:use std::any::Any; use core::fmt::Debug; trait ColTrait: std::fmt::Debug{ fn getself<T>(&self)->T; } #[derive(Debug)] struct DataCell<T>{ val:T, } // 阅读全文
posted @ 2022-07-21 13:26 CrossPython 阅读(69) 评论(0) 推荐(0)
摘要:use std::{any::{Any, TypeId}, fmt::Debug}; use downcast_rs::Downcast; fn is_string<T: ?Sized + Any>(_s: &T) -> bool { TypeId::of::<String>() == TypeId 阅读全文
posted @ 2022-07-21 09:19 CrossPython 阅读(53) 评论(0) 推荐(0)
摘要:use std::collections::HashMap; use std::ops::Index; #[derive(Debug,Clone)] struct Cell{ name:String } type Col = HashMap<String, Vec<Cell>>; #[derive( 阅读全文
posted @ 2022-07-20 15:20 CrossPython 阅读(56) 评论(0) 推荐(0)
摘要:https://github.com/jinliming2/Chrome-Charset 阅读全文
posted @ 2022-07-19 13:29 CrossPython 阅读(714) 评论(0) 推荐(0)
摘要:基本技巧快速启动VsCode安装后,会自动写入环境变量,终端输入code即可唤起VsCode应用程序。 常用快捷键ctrl + p快速搜索文件并跳转,添加:可以跳转到指定行ctrl + shift + p 根据您当前的上下文访问所有可用命令。ctrl + shift + c在外部打开终端并定位到当前 阅读全文
posted @ 2022-07-19 10:13 CrossPython 阅读(216) 评论(0) 推荐(0)
摘要:trait Select<T>{ fn select<'a>(self, slice:&'a Vec<T>)->Vec<&T>; } impl<T> Select<T> for usize { fn select<'a>(self, slice:&'a Vec<T>)->Vec<&T> { matc 阅读全文
posted @ 2022-07-16 23:41 CrossPython 阅读(23) 评论(0) 推荐(0)
摘要:#[derive(Clone, Copy)] enum Args<'a> { Idx(usize), IdxList(&'a [usize]), } fn get_data<'a, T>(arr: &'a [T], idxs: Args<'a>) -> Vec<&'a T> { match idxs 阅读全文
posted @ 2022-07-16 17:54 CrossPython 阅读(70) 评论(0) 推荐(0)
摘要:use std::any::Any; macro_rules! requests{ ( $($key:expr=> $value:expr);* $(;)? ) => { let mut url: Box<dyn Any> = Box::new(""); let mut method: Box<dy 阅读全文
posted @ 2022-07-16 15:26 CrossPython 阅读(139) 评论(0) 推荐(0)
摘要:#[derive(Debug)] enum Cell{ s(String), f(f64), i(i64), b(bool) } #[derive(Debug)] struct Col{ title:String, data:Vec<Cell> } type DataFrame = Vec<Col> 阅读全文
posted @ 2022-07-16 11:54 CrossPython 阅读(14) 评论(0) 推荐(0)
摘要:use std::collections::HashMap; macro_rules! map { ($($key:expr => $val:expr),*) => {{ let mut hm = HashMap::new(); $(hm.insert($key, $val);)* hm }}; / 阅读全文
posted @ 2022-07-15 23:34 CrossPython 阅读(35) 评论(0) 推荐(0)
摘要:#[derive(Debug)] enum Cell { s(String), i(i64), f(f64) } type Col = Vec<Cell>; trait ColumnFactory { fn build(self) -> Cell; } impl ColumnFactory for 阅读全文
posted @ 2022-07-15 22:54 CrossPython 阅读(851) 评论(1) 推荐(1)
摘要:impl Trait:静态分发dyn Trait:动态分发 静态分发:在编译期就确定了具体返回类型,函数只能返回一种类型。动态分发:在运行时才能确定具体返回类型,函数可以返回多种类型。 Trait Object:指向trait的指针,假设Animal是一个triait,那么&Animal和Box<A 阅读全文
posted @ 2022-07-15 10:26 CrossPython 阅读(145) 评论(0) 推荐(0)
摘要:window.setInterval(function(){ var refreshHours = new Date().getHours(); var refreshMin = new Date().getMinutes(); var refreshSec = new Date().getSeco 阅读全文
posted @ 2022-07-14 10:29 CrossPython 阅读(135) 评论(0) 推荐(0)
摘要:1. var ajax = { abort: function () {} //定义一个空的方法, 是为了下面ajax.abort()不报错 }; setInterval(function () { ajax.abort(); //每次提交前, 先放弃上一次ajax的提交, 这样就不会同时有多个aj 阅读全文
posted @ 2022-07-14 09:53 CrossPython 阅读(417) 评论(0) 推荐(0)
摘要:window.onerror=function(){ window.location.reload(true); } 阅读全文
posted @ 2022-07-14 09:34 CrossPython 阅读(28) 评论(0) 推荐(0)
摘要:插播:python生成字典的方法 直接创建/键值对创建:dic={'a':1,'b':2,'c':3} dic=dict(a=1,b=2,c=3) 二元组列表创建:list=[('a',1),('b',2),('c',3)] dic=dict(list) 用dict和zip:dic=dict(zip 阅读全文
posted @ 2022-07-13 14:32 CrossPython 阅读(647) 评论(0) 推荐(0)
摘要:fn main() { let values = vec![1, 2, 3]; for v in values.into_iter() { println!("{}", v) } // 下面的代码将报错,因为 values 的所有权在上面 `for` 循环中已经被转移走 // println!("{ 阅读全文
posted @ 2022-07-11 21:58 CrossPython 阅读(43) 评论(0) 推荐(0)
摘要:https://blog.csdn.net/wowotuo/article/details/116489754 所有 trait 的方法是顺序放在一起,并没有区分方法属于哪个 trait,这样也就导致无法进行 upcast,社区内有 RFC 2765 在追踪这个问题,感兴趣的读者可参考,这里就不讨论 阅读全文
posted @ 2022-07-11 16:45 CrossPython 阅读(507) 评论(0) 推荐(0)
摘要:fn main() { let s = String::from("hello, 世界"); let slice1 = &s[0..1]; //提示: `h` 在 UTF-8 编码中只占用 1 个字节 assert_eq!(slice1, "h"); let slice2 = &s[7..=9];/ 阅读全文
posted @ 2022-07-10 17:44 CrossPython 阅读(150) 评论(0) 推荐(0)
摘要:struct Sheep {} struct Cow {} trait Animal { fn noise(&self) -> String; } impl Animal for Sheep { fn noise(&self) -> String { "baaaaah!".to_string() } 阅读全文
posted @ 2022-07-10 12:39 CrossPython 阅读(46) 评论(0) 推荐(0)
摘要:struct Val<T> { val: T,} impl<T> Val<T> { fn value(&self) -> &T { &self.val }} fn main() { let x = Val{ val: 3.0 }; let y = Val{ val: "hello".to_strin 阅读全文
posted @ 2022-07-09 21:43 CrossPython 阅读(51) 评论(0) 推荐(0)
摘要:fn main() { let a = [4,3,2,1]; // 通过索引和值的方式迭代数组 `a` for (i,v) in a.iter().enumerate() { println!("第{}个元素是{}",i+1,v); }} fn main() { let names = [Strin 阅读全文
posted @ 2022-07-09 18:49 CrossPython 阅读(70) 评论(0) 推荐(0)
摘要:struct Unit;trait SomeTrait { // ...定义一些行为} // 我们并不关心结构体中有什么数据( 字段 ),但我们关心它的行为。// 因此这里我们使用没有任何字段的单元结构体,然后为它实现一些行为impl SomeTrait for Unit { }fn main() 阅读全文
posted @ 2022-07-09 15:59 CrossPython 阅读(70) 评论(0) 推荐(0)
摘要:先从字符串到json a = json.loads(str) 处理完毕后再转json b = json.dumps(a).encode('utf8').decode('unicode-escape') 阅读全文
posted @ 2022-07-08 16:56 CrossPython 阅读(171) 评论(0) 推荐(0)
摘要:rust dbg打印 阅读全文
posted @ 2022-07-05 21:19 CrossPython 阅读(31) 评论(0) 推荐(0)
摘要:opacity :设置背景透明度 rgba():设置颜色透明度 1.opacity 属性的效果是给背景颜色添加透明度,取值范围是0~1, 但也会让处于背景颜色中的字体一同透明, 单用效果很好 2.rgba(): R:红色值。正整数 (0~255) G:绿色值。正整数 (0~255) B:蓝色值。正整 阅读全文
posted @ 2022-07-04 11:14 CrossPython 阅读(591) 评论(0) 推荐(0)
摘要:cratesrust-analysisTOML language supportrust -hint开启? 阅读全文
posted @ 2022-07-02 23:14 CrossPython 阅读(60) 评论(0) 推荐(0)
摘要:[dependencies] reqwest = { version = "0.11", default-features = false, features = ["rustls-tls", "blocking"] } html2md = "0.2" use std::fs; fn main() 阅读全文
posted @ 2022-07-02 23:05 CrossPython 阅读(34) 评论(0) 推荐(0)
摘要:https://kaisery.github.io/trpl-zh-cn/foreword.html rust 的核心思想是 由程序员,语法,编译器 共同 维护 程序内的变量生成,使用,复制,转移和销毁。 基本数据类型 i8,i16,i32,i64,i128 // 有符号整数 u8,u16,u32, 阅读全文
posted @ 2022-07-02 21:29 CrossPython 阅读(181) 评论(0) 推荐(1)
摘要:改源码 requestium.py if isinstance(self.webdriver_options['prefs'], dict): download_dir = self.webdriver_options['prefs'].get('download.default_directory 阅读全文
posted @ 2022-07-02 16:18 CrossPython 阅读(48) 评论(0) 推荐(0)