Skip to content

Instantly share code, notes, and snippets.

@irh
irh / bacon.log
Created January 17, 2025 12:01
Hang in bacon after editing bacon.toml
12:56:27.463 [INFO] cli_log::init: Starting bacon v3.8.0 with log level DEBUG
12:56:27.464 [INFO] bacon::cli: args: Args {
help: false,
version: false,
prefs: false,
headless: false,
summary: false,
no_summary: false,
wrap: false,
no_wrap: false,
@irh
irh / variadic_closures.rs
Created September 29, 2022 08:44
An example of implementing a method that accepts closures with different arguments.
// An example of implementing a method that accepts closures with different input arguments.
// The trick to avoid Rust complaining about conflicting implementations is to specify
// the arguments for each specialization in a separate type parameter.
// See https://geo-ant.github.io/blog/2021/rust-traits-and-variadic-functions/
fn main() {
let mut foo = Foo::default();
foo.add_fn(|| 0);
foo.add_fn(|a| a);
@irh
irh / concepts_polymorphism.rs
Last active August 28, 2016 11:16
A Rust version of Sean Parent's example of concepts-based polymorphism in C++
// ...from 'Inheritance Is The Base Class of Evil'
use std::fmt;
use std::rc::Rc;
fn white_space(count: usize) -> String {
std::iter::repeat(' ').take(count).collect::<String>()
}
trait Drawable {