Skip to content

Instantly share code, notes, and snippets.

The Rust Playground rust-play

View GitHub Profile
@rust-play
rust-play / playground.rs
Created Mar 20, 2019
Code shared from the Rust Playground
View playground.rs
use bytes::Bytes;
use futures::Stream;
use std::net::SocketAddr;
pub struct ServFail;
/// `Handler` is cloned and then `.handle()` is called for each incoming message.
pub trait Handler: Clone {
/// Returning `Err(ServFail)` generates a SERVFAIL response.
fn handle(&self, query: Query) -> Result<(), ServFail>;
@rust-play
rust-play / playground.rs
Created Mar 20, 2019
Code shared from the Rust Playground
View playground.rs
use bytes::Bytes;
use futures::Stream;
use std::net::SocketAddr;
pub struct ServFail;
/// `Handler` is cloned and then `.handle()` is called for each incoming message.
pub trait Handler: Clone {
/// Returning `Err(ServFail)` generates a SERVFAIL response.
fn handle(&self, query: Query) -> Result<(), ServFail>;
@rust-play
rust-play / playground.rs
Created Mar 20, 2019
Code shared from the Rust Playground
View playground.rs
fn main() {
let mut array: [String; 7] = Default::default();
attempt(&mut array);
println!("{:?}", array);
}
fn attempt(array: &mut [String]){
let a = "amit".to_string();
array[0] = a;
@rust-play
rust-play / playground.rs
Created Mar 20, 2019
Code shared from the Rust Playground
View playground.rs
fn main() {
let mut array: [String; 7] = Default::default();
attempt(&mut array);
println!("{:?}", array);
}
fn attempt(array: &mut [String]){
let a = "amit".to_string();
array[0] = a;
@rust-play
rust-play / playground.rs
Created Mar 20, 2019
Code shared from the Rust Playground
View playground.rs
fn main() {
let mut array: [String; 7] = Default::default();
attempt(&mut array);
println!("{:?}", array);
}
fn attempt(array: &mut [String]){
let a = "amit".to_string();
array[0] = a;
@rust-play
rust-play / playground.rs
Created Mar 20, 2019
Code shared from the Rust Playground
View playground.rs
//! Hello
#![deny(missing_docs)]
#[allow(missing_docs)]
#[macro_export]
macro_rules! hello {
() => ()
}
@rust-play
rust-play / playground.rs
Created Mar 20, 2019
Code shared from the Rust Playground
View playground.rs
//! Hello
#![deny(missing_docs)]
#[macro_export]
#[allow(missing_docs)]
macro_rules! hello {
() => ()
}
@rust-play
rust-play / playground.rs
Created Mar 20, 2019
Code shared from the Rust Playground
View playground.rs
use std::ops::Sub;
struct Foo {
value: i32
}
trait MuhTrait {
fn traitfn(self, other: Self) -> Self;
}
@rust-play
rust-play / playground.rs
Created Mar 20, 2019
Code shared from the Rust Playground
View playground.rs
#![deny(missing_docs)]
#[macro_export]
#[allow(missing_docs)]
macro_rules! hello {
() => ()
}
@rust-play
rust-play / playground.rs
Created Mar 20, 2019
Code shared from the Rust Playground
View playground.rs
fn minimalNumberOfCoins(coins: Vec<i32>, price: i32) -> i32 {
let mut dp = vec![100; (price + 1) as usize];
dp[0] = 0;
for coin in &coins {
for target in coin..price {
dp[price as usize] = min(1 + dp[(price - coin) as usize], dp[(price) as usize])
}
}
return dp[price as usize];
}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.