Skip to content

Instantly share code, notes, and snippets.

The Rust Playground rust-play

Block or report user

Report or block rust-play

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rust-play
rust-play / playground.rs
Created Jul 22, 2019
Code shared from the Rust Playground
View playground.rs
fn main() {
println!("Hello, world!");
let mut a;;
a = 2;
println!("{:?}",a);
}
@rust-play
rust-play / playground.rs
Created Jul 22, 2019
Code shared from the Rust Playground
View playground.rs
fn main() {
println!("Hello, world!");
let mut a;
a = 0;
println!("{:?}",a);
}
@rust-play
rust-play / playground.rs
Created Jul 22, 2019
Code shared from the Rust Playground
View playground.rs
fn main() {
let mut x = 5;
println!("The value of x is: {}", x);
x = 909089uio;
println!("The value of x is: {}", x);
}
@rust-play
rust-play / playground.rs
Created Jul 22, 2019
Code shared from the Rust Playground
View playground.rs
type Mad = Option<Option<Option<Option<Option<Option<Option<Option<Option<Option<Option<Option<bool>>>>>>>>>>>>;
fn main() {
println!("{}", std::mem::size_of::<Mad>())
}
@rust-play
rust-play / playground.rs
Created Jul 22, 2019
Code shared from the Rust Playground
View playground.rs
fn main() -> Result<(), Box<dyn std::fmt::Debug>> {
let contents =
std::fs::read_to_string("my.txt").map_err(|e| Box::new(e) as Box<dyn std::fmt::Debug>)?;
let number = contents
.parse::<i32>()
.map_err(|e| Box::new(e) as Box<dyn std::fmt::Debug>)?;
println!("Number is {}!", number);
return Ok(());
}
@rust-play
rust-play / playground.rs
Created Jul 22, 2019
Code shared from the Rust Playground
View playground.rs
#![allow(unused)]
fn main() {
use std::path::{Path, PathBuf};
let path = Path::new("/test/haha/foo.txt/");
assert_eq!(path.strip_prefix("/"), Ok(Path::new("test/haha/foo.txt")));
assert_eq!(path.strip_prefix("/test"), Ok(Path::new("haha/foo.txt")));
assert_eq!(path.strip_prefix("/test/"), Ok(Path::new("haha/foo.txt")));
assert_eq!(path.strip_prefix("/test/haha/foo.txt"), Ok(Path::new("")));
@rust-play
rust-play / playground.rs
Created Jul 22, 2019
Code shared from the Rust Playground
View playground.rs
use std::net::{SocketAddr, UdpSocket};
use std::sync::{Arc, Mutex};
use serde::Serialize;
use serde_json::Value;
#[derive(Serialize)]
pub struct Peer {
ip: SocketAddr,
}
@rust-play
rust-play / playground.rs
Created Jul 22, 2019
Code shared from the Rust Playground
View playground.rs
struct Rectangle {
width: u32,
height: u32,
}
fn main() {
let rect1 = Rectangle { width: 30, height: 50 };
println!(
"The area of the rectangle is {} square pixels.",
@rust-play
rust-play / playground.rs
Created Jul 22, 2019
Code shared from the Rust Playground
View playground.rs
use std::net::{SocketAddr, UdpSocket};
use std::sync::{Arc, Mutex};
use serde::Serialize;
use serde_json::Value;
#[derive(Serialize)]
pub struct Peer {
ip: SocketAddr,
}
@rust-play
rust-play / playground.rs
Created Jul 22, 2019
Code shared from the Rust Playground
View playground.rs
fn main() {
println!("Hello, world!");
}
You can’t perform that action at this time.