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
// This means "callback takes no arguments and can return anything, but I won't | |
// look at the result." | |
function foo(callback: ()=>void) { | |
callback(); | |
} | |
// Since this uses the union operator, one would expect it to accept all of the | |
// types allowed by the previous signature and possibly more. Instead, now it | |
// will only accept undefined or a PromiseLike when called directly. | |
function bar(callback: ()=>void|PromiseLike<void>) { |
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 python3 | |
import argparse | |
parser = argparse.ArgumentParser(description='Create a device mapper table from a ddrescue map file. ' | |
'Blocks that are marked as bad will be mapped to the error target, while successfully-read ' | |
'blocks will be passed through to the device. The dm table will be written to stdout so it can ' | |
'be piped directly into dmsetup.') | |
parser.add_argument('mapfile', help='The ddrescue map file to convert') | |
parser.add_argument('device', help='The device containing the image that corresponds to the map file. (typically a loop device)') |
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::ops::Deref; | |
use std::rc::Rc; | |
use std::sync::Arc; | |
trait RefCounted<T>: Clone + Deref<Target=T> { | |
fn new(value: T) -> Self; | |
} | |
impl<T> RefCounted<T> for Rc<T> { | |
fn new(value: T) -> Self { |
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
#include <iostream> | |
#include <map> | |
#include <cmath> | |
#include <vector> | |
// Sieve of Eratosthenes | |
// | |
// This is a simple implementation of the Sieve of Eratosthenes, implemented in | |
// C++. This is a port of the excellent and very terse implementation by David | |
// Eppstein[0]. This port is meant to be a straightforward naive port of the |
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::boxed; | |
use std::cell::{Cell, UnsafeCell}; | |
use std::cmp::{Ordering, max}; | |
use std::fmt; | |
use std::hash::{Hasher, Hash}; | |
use std::intrinsics::{abort, assume}; | |
use std::isize; | |
use std::marker::PhantomData; | |
use std::mem::{self, forget, min_align_of, size_of, transmute}; | |
use std::ops::Deref; |
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::boxed; | |
use std::cell::Cell; | |
use std::cmp::Ordering; | |
use std::fmt; | |
use std::hash::{Hasher, Hash}; | |
use std::marker::PhantomData; | |
use std::mem::{forget, min_align_of, size_of}; | |
use std::ops::Deref; | |
use std::ptr; | |
use std::rt::heap::deallocate; |
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
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT | |
// file at the top-level directory of this distribution and at | |
// http://rust-lang.org/COPYRIGHT. | |
// | |
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
// option. This file may not be copied, modified, or distributed | |
// except according to those terms. |
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 widen::Widen; | |
use widen::widen as w; // Use w as shorthand for widening | |
// Contains Widen trait, impls, and widen() convenience function | |
mod widen { | |
// Performs a lossless conversion of an integer to a wider type | |
pub trait Widen<T> { | |
fn widen(self) -> T; | |
} |