Skip to content

Instantly share code, notes, and snippets.

@dstu
dstu / playground.rs
Created April 24, 2018 23:24 — forked from rust-play/playground.rs
Code shared from the Rust Playground
use array::with;
mod array {
use std::marker::PhantomData;
use std::ops::{Deref, DerefMut};
#[derive(Clone,Copy)]
pub struct InvariantLifetime<'id>(
PhantomData<*mut &'id ()>);
@dstu
dstu / playground.rs
Created December 17, 2015 01:45 — forked from anonymous/playground.rs
Shared via Rust Playground
#![feature(drain)]
use std::cmp::Ordering;
pub fn main() {
let mut x_vec = vec![1, 2, 3, 4];
let mut y_vec = vec![3, 4, 5];
// Slightly contrived example: iterate through two sorted sequences in
// tandem, merging them into a new sequence.
let mut xs = x_vec.drain(0..);
@dstu
dstu / gist:4489529
Last active December 10, 2015 20:38 — forked from anonymous/gist:4489522
Is this a bug in Perl?
use strict;
use warnings;
use Data::Dumper;
my $things = { foo => 'bar' };
foreach my $word (qw(foo baz bar quux)) {
my $count = grep { defined } $things->{$word};
print "$count\n";
}