Skip to content

Instantly share code, notes, and snippets.

View ZhangHanDong's full-sized avatar
🦀
Rustacean

Alex ZhangHanDong

🦀
Rustacean
  • Beijing, China
View GitHub Profile

Rust in Large Organizations

Initially taken by Niko Matsakis and lightly edited by Ryan Levick

Agenda

  • Introductions
  • Cargo inside large build systems
  • FFI
  • Foundations and financial support
@ZhangHanDong
ZhangHanDong / string-conversion.rs
Created October 12, 2020 22:08 — forked from jimmychu0807/string-conversion.rs
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@ZhangHanDong
ZhangHanDong / playground.rs
Created September 24, 2020 21:36 — forked from anonymous/playground.rs
Rust code shared from the playground
impl<
'four>For for
& 'four for<
'fore>For where
for<'fore>For:For
{fn four( self:&&
'four for <'fore>
For){ print!(
"four" )}} fn
main(){ four(&(
@ZhangHanDong
ZhangHanDong / fizzbuzz.rs
Created August 21, 2020 14:07 — forked from mre/fizzbuzz.rs
Fizzbuzz in Rust
#![feature(generators)]
#![feature(generator_trait)]
use std::ops::{Generator, GeneratorState};
fn fizzbuzz_println(upto: u64) {
for i in 0..upto {
if i % 3 == 0 && i % 5 == 0 {
println!("FizzBuzz");
} else if i % 3 == 0 {
#![warn(rust_2018_idioms)]
#[derive(Debug)]
pub struct StrSplit<'haystack, D> {
remainder: Option<&'haystack str>,
delimiter: D,
}
impl<'haystack, D> StrSplit<'haystack, D> {
pub fn new(haystack: &'haystack str, delimiter: D) -> Self {
@ZhangHanDong
ZhangHanDong / design_is_import.rs
Created July 19, 2020 10:49 — forked from rust-play/playground.rs
Code shared from the Rust Playground
pub struct Monster {
hp: u8, // health points
sp: u8, // spell points
friends: Vec<Friend>,
}
pub struct Friend {
loyalty: u8,
}
@ZhangHanDong
ZhangHanDong / immutable_and_mutable_tip.rs
Last active July 19, 2020 10:22 — forked from rust-play/playground.rs
Code shared from the Rust Playground
pub struct Monster {
hp: u8, // health points
sp: u8, // spell points
friends: Vec<Friend>,
}
pub struct Friend {
loyalty: u8,
}
@ZhangHanDong
ZhangHanDong / trait_and_trait_object.rs
Last active July 18, 2020 11:58 — forked from rust-play/playground.rs
Code shared from the Rust Playground
trait A{
fn a(&self);
}
trait B{
fn b(&self);
}
impl B for A{
@ZhangHanDong
ZhangHanDong / ok_bool..rs
Created July 17, 2020 03:37 — forked from rust-play/playground.rs
Code shared from the Rust Playground
fn t() -> Result<bool, ()> {
Ok(
Ok(true)? && Ok(true)?
)
}
fn main(){
@ZhangHanDong
ZhangHanDong / defer_drop.rs
Last active July 13, 2020 11:39 — forked from rust-play/playground.rs
Code shared from the Rust Playground
use std::collections::HashMap;
use std::thread;
use std::time::Instant;
const NUM_ELEMENTS: usize = 1000000;
type HeavyThings = HashMap<usize, Vec<usize>>;
fn main() {
let heavy_things_1 = make_heavy_things();