Skip to content

Instantly share code, notes, and snippets.

@o0Ignition0o
o0Ignition0o / main.rs
Created December 3, 2019 21:38
on joue avec des results
use rand::prelude::*;
#[derive(Debug)]
struct JaiPasDentierError {}
#[derive(Debug)]
struct JaiPasReussiError {}
#[derive(Debug)]
enum MyError {
@o0Ignition0o
o0Ignition0o / mount.rs
Created November 4, 2018 12:39
yew rust framework: mount component to dom macro
pub enum MountError {
QuerySelectorError,
ElementNotFound(String)
}
impl From<TODO> for MountError {
fn from(_: TODO) -> Self {
MountError::QuerySelectorError
}
#![crate_type = "staticlib"]
//#![feature(test)]
//extern crate test;
use std::slice;
use std::str;
#[inline]
fn try_apply_digit(current_octet: u8, digit_to_apply: u8) -> Option<u8> {
current_octet.checked_mul(10)?.checked_add(digit_to_apply)
@o0Ignition0o
o0Ignition0o / lib.rs
Created July 31, 2018 12:14
is_valid_ipv4
use std::slice;
pub fn is_valid_ipv4_addr<'a>(addr: &'a [u8]) -> bool {
let mut current_octet: Option<u8> = None;
let mut dots: u8 = 0;
for c in addr {
let c = *c as char;
match c {
'.' => {
#![crate_type = "staticlib"]
#![feature(test)]
extern crate test;
extern crate libc;
use std::slice;
fn is_valid_ipv4_addr<'a>(addr: &'a [char]) -> bool {
let mut maybe_octet: Option<u8> = None;
@o0Ignition0o
o0Ignition0o / lib.rs
Last active July 29, 2018 21:08
is_valid_ipv4_addr
#![crate_type = "staticlib"]
#![feature(test)]
extern crate test;
extern crate libc;
use std::slice;
fn is_valid_ipv4_addr<'a>(addr: &'a [u8]) -> bool {
let mut maybe_octet: Option<u8> = None;
[[package]]
name = "actix"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"actix_derive 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam-channel 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@o0Ignition0o
o0Ignition0o / main.rs
Created June 8, 2018 12:53
impl trait vec !
trait MakesNoise {
fn make_noise(self) -> ();
}
struct Dog;
struct Cat;
impl MakesNoise for Dog {
fn make_noise(self) -> () {
println!("WOOF WOOF");
@o0Ignition0o
o0Ignition0o / main.rs
Last active April 24, 2018 09:53
Add a vector of actix routes
extern crate actix;
extern crate actix_web;
extern crate env_logger;
use actix_web::{server, App, HttpRequest};
struct Route {
path: String,
action: fn(HttpRequest) -> String,
}

Keybase proof

I hereby claim:

  • I am o0ignition0o on github.
  • I am jeremylempereur (https://keybase.io/jeremylempereur) on keybase.
  • I have a public key whose fingerprint is 93E1 F8B0 6CF0 241E 5363 B9E9 E255 4847 D470 F328

To claim this, I am signing this object: