文章列表

1.9k2 分钟

一个基于 fread 和 fwrite 的 C++ 快速输入输出模板(Fast I/O)。 # 源码 #include <bits/stdc++.h> using namespace std; namespace fastio { static constexpr int SZ = 1 << 20; char inbuf[SZ], outbuf[SZ], *p1 = inbuf, *p2 = inbuf, *p3 = outbuf; inline ch
8111 分钟

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub. # Quick Start # Create a new post $ hexo new "My New Post" More info: Writing # Run server $ he
1.1k1 分钟

通过这篇文章,我们将来学习Rust 最独特的特性—— 所有权。 # 所有权规则 首先,让我们看一下所有权的规则。当我们通过举例说明时,请谨记这些规则: Rust 中的每一个值都有一个被称为其 所有者(owner)的变量。 值在任一时刻有且只有一个所有者。 当所有者(变量)离开作用域,这个值将被丢弃。 # 引用与借用 在 Rust 中,如果我们想使用一个变量的值,但又不想获取它的所有权,我们可以使用 引用(Reference)。 如果我们需要在函数中使用一个值但不获取所有权,通常的做法可能需要将所有权传进去再传出来,但是这样的做法太繁琐了。因此在 Rust 中,我们可以通过引用代替这种将所有