This file contains hidden or 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 array::with; | |
mod array { | |
use std::marker::PhantomData; | |
use std::ops::{Deref, DerefMut}; | |
#[derive(Clone,Copy)] | |
pub struct InvariantLifetime<'id>( | |
PhantomData<*mut &'id ()>); |
This file contains hidden or 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
#![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..); |
This file contains hidden or 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 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"; | |
} |