上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 79 下一页
摘要: use std::borrow::Borrow; /** 21. Merge Two Sorted Lists https://leetcode.com/problems/merge-two-sorted-lists/ You are given the heads of two sorted li 阅读全文
posted @ 2022-03-17 11:22 johnny_zhao 阅读(46) 评论(0) 推荐(0) 编辑
摘要: use std::collections::{HashMap, HashSet}; /** 997. Find the Town Judge https://leetcode.com/problems/find-the-town-judge/ In a town, there are n peopl 阅读全文
posted @ 2022-03-16 00:47 johnny_zhao 阅读(27) 评论(0) 推荐(0) 编辑
摘要: use std::collections::HashSet; use std::collections::VecDeque; /** 841. Keys and Rooms https://leetcode.com/problems/keys-and-rooms/ There are n rooms 阅读全文
posted @ 2022-03-13 00:48 johnny_zhao 阅读(34) 评论(0) 推荐(0) 编辑
摘要: Rust的所有权机制,要求一个资源同一时刻有且只能有一个拥有所有权的绑定或&mut引用,目的为保证内存的安全。在大多数情况下,都没有问题,但是考虑以下情况: 在图数据结构中,多个边可能会拥有同一个节点,该节点直到没有边指向它时,才应该被释放清理。 在多线程中,多个线程可能会持有同一个数据,但是你受限 阅读全文
posted @ 2022-02-22 23:15 johnny_zhao 阅读(1717) 评论(0) 推荐(0) 编辑
摘要: use std::borrow::Borrow; use std::cell::RefCell; use std::collections; use std::collections::HashMap; use std::rc::Rc; /** 652. Find Duplicate Subtree 阅读全文
posted @ 2022-02-21 20:03 johnny_zhao 阅读(27) 评论(0) 推荐(0) 编辑
摘要: 我们在学习Rust的借用,引用时,会遇到References(引用)、borrowing(借用)、&关键字、*关键字,他们之间的关系非常困惑。 所有权不仅可以转移(原变量会丢失数据的所有权),还可以通过引用的方式来借用数据的所有权(borrow ownership)。 我们整理下相关问题: 1. & 阅读全文
posted @ 2022-02-19 18:08 johnny_zhao 阅读(408) 评论(0) 推荐(0) 编辑
摘要: 简单工厂模式 trait Login { fn verify(&self, name: String, password: String) -> bool; } enum LoginType { Domain, Password, } struct DomainLogin {} impl Login 阅读全文
posted @ 2022-02-16 17:10 johnny_zhao 阅读(118) 评论(0) 推荐(0) 编辑
摘要: #[cfg] #[cfg]允许我们基于一个传递给编译器的标记编译代码。它有两种形式: #[cfg(foo)] fn foo(){ } #[cfg(bar="baz")] fn bar(){ } 它还有一些帮助选项: #[cfg(any(unix,target_pointer_width = "32" 阅读全文
posted @ 2022-01-30 15:50 johnny_zhao 阅读(364) 评论(0) 推荐(0) 编辑
摘要: 请看这里 学习相关 学习相关 阅读全文
posted @ 2022-01-20 10:47 johnny_zhao 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 在android开发的时候,有时候会遇到这样的问题 Error:Execution failed for task ':test:processDebugManifest'.> Manifest merger failed with multiple errors, see logs但是除了这个lo 阅读全文
posted @ 2022-01-13 15:14 johnny_zhao 阅读(968) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 79 下一页