Skip to content

Instantly share code, notes, and snippets.

Brad Gibson U007D

Block or report user

Report or block U007D

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
View AutoFacGettingStarted.rs
#![feature(existential_type)]
use chrono::Local;
use std::io::{self, Write};
type Result<T> = std::result::Result<T, failure::Error>;
trait IOutput {
fn write(&self, content: &String) -> Result<()>;
}
struct ConsoleOutput {}
View AutoFacGettingStarted.cs
using System;
using Autofac;
namespace DemoApp
{
// This interface helps decouple the concept of
// "writing output" from the Console class. We
// don't really "care" how the Write operation
// happens, just that we can write.
public interface IOutput
@U007D
U007D / di.rs
Last active Apr 18, 2019
Simple Dependency Injection
View di.rs
#![feature(existential_type)]
type Result<T> = std::result::Result<T, failure::Error>;
trait MyTrait {
fn greet(&self) -> String;
}
struct MyType {}
View .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@U007D
U007D / default_clippy_lints.rs
Created Oct 6, 2018
Strict + Safety-Critical `clippy` default lint specification - current as per `clippy` v0.0.212 (2018-10-03)
View default_clippy_lints.rs
#![forbid(overflowing_literals,)]
#![deny(unsafe_code)] // Do not remove! Change to `allow` to explicitly opt-in to using `unsafe` (facilitates auditing)
// vvv Safety-critical application lints (pedantic: use for safety-critical applications only) vvv
#![deny(clippy::cast_possible_truncation, clippy::cast_possible_wrap, clippy::cast_precision_loss,
clippy::cast_sign_loss, clippy::float_cmp_const, clippy::indexing_slicing, clippy::integer_arithmetic,
clippy::maybe_infinite_iter, clippy::option_unwrap_used, clippy::result_unwrap_used,)]
// ^^^ End of safety-critical lint section ^^^
#![warn(clippy::clone_on_ref_ptr, clippy::decimal_literal_representation, clippy::default_trait_access,
clippy::doc_markdown, clippy::else_if_without_else, clippy::empty_enum, clippy::enum_glob_use,
clippy::expl_impl_clone_on_copy, clippy::fallible_impl_from, clippy::filter_map, clippy::if_not_else,
@U007D
U007D / roll_validator.rs
Last active Jul 15, 2018
evolution from iterative to functional validator for bgk
View roll_validator.rs
//does not work as intended :(
#[inline]
pub(super) fn validate_frame(roll: u8) -> Result<u8> {
let mut frame_validator = || -> Error {
for frame in Game::FIRST_FRAME..=Game::LAST_FRAME {
let first_roll = roll;
yield Ok(first_roll);
// this frame has a second roll if it's the last frame OR if first roll was not a strike
@U007D
U007D / 1.26.0_stabilizations.rs
Created Mar 30, 2018
Rust 1.26.0 stablizations
View 1.26.0_stabilizations.rs
brad@SocratesV:~/Development/rust/rust$ rg 1.26.0
src/bootstrap/channel.rs
27:pub const CFG_RELEASE_NUM: &str = "1.26.0";
src/libstd/lib.rs
437:#[stable(feature = "i128", since = "1.26.0")]
467:#[stable(feature = "i128", since = "1.26.0")]
src/libstd/path.rs
909:#[stable(feature = "fused", since = "1.26.0")]
View c++17_steveklabnik_excerpt_tt.rs
fn main() {
let opt = Opt::from_args();
if let Err(err) = run(&opt) {
eprintln!("error: {}", err);
std::process::exit(1);
}
}
// ->
@U007D
U007D / playground.rs
Created Feb 14, 2018 — forked from anonymous/playground.rs
Rust code shared from the playground
View playground.rs
use std::fmt;
#[derive(Debug, Clone, Copy)]
pub enum CardinalPoint {
North = 0x2191, // ↑
NorthEast = 0x2197, // ↗
East = 0x2192, // →
SouthEast = 0x2198, // ↘
South = 0x2193, // ↓
SouthWest = 0x2199, // ↙
You can’t perform that action at this time.