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
#![feature(optin_builtin_traits)] | |
use std::marker::PhantomData; | |
struct Nil; | |
struct Cons<H, T>(H, T); | |
struct Pair<A, B>(A, B); | |
trait Lookup_<S, Env> { type Type; } | |
type Lookup<S, Env> = <() as Lookup_<S, Env>>::Type; |
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
#![feature(optin_builtin_traits)] | |
use std::marker::PhantomData; | |
struct Nil; | |
struct Cons<H, T>(H, T); | |
struct Pair<A, B>(A, B); | |
trait Lookup_<S, Env> { type Type; } | |
type Lookup<S, Env> = <() as Lookup_<S, Env>>::Type; |
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
#![feature(optin_builtin_traits)] | |
use std::marker::PhantomData; | |
trait Lookup<K> { | |
type V; | |
fn get(&self) -> &Self::V; | |
} | |
struct Nil; |
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
#![feature(optin_builtin_traits)] | |
use std::marker::PhantomData; | |
trait Lookup<K> { | |
type V; | |
fn get(&self) -> &Self::V; | |
} | |
struct Nil; |
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
#[test] | |
fn simple_test() { | |
// A Mailbox consists of an Address and a Signal. | |
// Values sent into the Address show up as events on the Signal. | |
let input1 = Mailbox::new(0); // The default value of this input is 0. | |
let input2 = Mailbox::new(0); | |
let input3 = Mailbox::new(0); | |
// This test demonstrates updates propagating from a lift2's inputs updating all at once and one at a time. | |
let mapped = lift2( | |
lift2(input1.signal, input3.signal.clone(), |x, y| x + y), // Both this signal |
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::collections::HashMap; | |
use std::marker::PhantomData; | |
use std::collections::hash_map; | |
pub trait DiffableIters<'a, T: Diffable> where T::Key: 'a, T::ListChild: 'a { | |
type KeyIter: Iterator<Item=&'a T::Key>; | |
type ListChildIter: Iterator<Item=&'a T::ListChild>; | |
} | |
pub type KeyIter<'a, T> = <T as DiffableIters<'a, T>>::KeyIter; |
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::any::Any; | |
use std::rc::Rc; | |
trait AsAny { | |
fn as_any(&self) -> &Any; | |
} | |
impl<T: Any> AsAny for T { | |
fn as_any(&self) -> &Any { 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
trait Merge<A, B> { | |
type Out; | |
fn merge(a: A, b: B) -> Self::Out; | |
} | |
type MergeOut<A, B> = <() as Merge<A, B>>::Out; | |
fn merge<A, B>(a: A, b: B) -> MergeOut<A, B> where (): Merge<A, B> { | |
<() as Merge<A, B>>::merge(a, b) | |
} | |
struct Unknown; | |
macro_rules! derive_merge_unknown { |
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::cell::RefCell; | |
use std::collections::HashMap; | |
use std::hash::{ Hash, SipHasher, Hasher }; | |
thread_local!(static SYMBOL_HASHES: RefCell<HashMap<(*const u8, usize), u64>> = RefCell::new(HashMap::new())); | |
struct StaticSymbol { | |
string: &'static str, | |
hash: u64, | |
} |
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
let specs = lime_suite::connected_devices()?; | |
let device = specs[0].open()?.unwrap(); | |
device.init()?; // put into default state | |
device.set_sample_rate(10.0e6)?; | |
let channel = &device.channels(Dir::Rx)?[0]; | |
channel.set_enabled(true)?; | |
channel.set_frequency(1575.42e6)?; | |
channel.antennas()?["LNA_H"].select()?; | |
let stream = channel.create_stream(StreamConfig::<i16> { | |
fifo_size: 1024 * 128, |