This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.annotation.tailrec | |
object S99 { | |
object S99Lists { | |
@tailrec | |
def last[A](list: List[A]): A = list match { | |
case Nil => throw new IllegalArgumentException | |
case List(x) => x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!cargo script | |
use std::fmt; | |
use std::fmt::{Display, Formatter}; | |
use std::marker::PhantomData; | |
use std::ops::Add; | |
use std::cmp::{Eq, PartialEq}; | |
struct Length<V, M> where M: Measure { | |
value: V, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(unused_imports)] | |
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))] | |
#[macro_use] | |
mod _input { | |
use std::fmt; | |
use std::io::{self, Read}; | |
use std::str::{self, FromStr}; | |
macro_rules! input { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env run-cargo-script | |
//!```cargo | |
//![dependencies] | |
//!chrono = "0.3.0" | |
//!irc = "0.11.6" | |
//!lazy_static = "0.2.6" | |
//!regex = "0.2.1" | |
//!rustbox = "0.9.0" | |
//!``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env run-cargo-script | |
//!```cargo | |
//![package] | |
//!authors = ["wariuni <wariuni@gmail.com>"] | |
//!name = tester | |
//!version = "0.1.0" | |
//! | |
//![dependencies] | |
//!toml = "0.3.2" | |
//!``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::borrow::Cow; | |
trait FromRefOpt<'a, T> { | |
fn from_ref_opt(option: Option<&'a T>) -> Self; | |
} | |
impl<'a, T: Clone + Default> FromRefOpt<'a, T> for Cow<'a, T> { | |
fn from_ref_opt(option: Option<&'a T>) -> Cow<'a, T> { | |
if let Some(x) = option { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! array { | |
[$x: tt; $n: tt] => {array!(@go ($n, $x) -> ())}; | |
(@end $x: tt) => {$x}; | |
(@go (1, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@end [$($x,)* $($xs)*]) }; | |
(@go (2, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (1, $($x), *) -> ($($x,)* $($xs)*))}; | |
(@go (3, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (2, $($x), *) -> ($($x,)* $($xs)*))}; | |
(@go (4, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (2, $($x,)* $($x), *) -> ($($xs)*))}; | |
(@go (5, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (4, $($x), *) -> ($($x,)* $($xs)*))}; | |
(@go (6, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (3, $($x,)* $($x), *) -> ($($xs)*))}; | |
(@go (8, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (4, $($x,)* $($x), *) -> ($($xs)*))}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env run-cargo-script | |
use std::fmt::Debug; | |
use std::io; | |
use std::io::{Read, Stdin}; | |
use std::str; | |
use std::str::FromStr; | |
macro_rules! array { | |
[$x: tt; $n: tt] => {array!(@go ($n, $x) -> ())}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[macro_use] | |
extern crate neon; | |
use neon::js::{JsInteger, JsString, JsUndefined, Object, Value}; | |
use neon::js::class::Class; | |
use neon::vm::{FunctionCall, JsResult, Lock, This, Throw}; | |
use std::ops::FnOnce; | |
use std::sync::{Arc, Mutex}; | |
use std::thread; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env run-cargo-script | |
//! ```cargo | |
//! [dependencies] | |
//! term = "0.4.6" | |
//! ``` | |
extern crate term; | |
use std::env; | |
use std::ffi::OsString; |
OlderNewer