Struct polytype::Arrow
[−]
[src]
pub struct Arrow { pub arg: Box<Type>, pub ret: Box<Type>, }
A curried function.
Examples
use polytype::{Type, Arrow}; let func = Arrow{ arg: Box::new(Type::Variable(0)), ret: Box::new(Type::Arrow(Arrow{ arg: Box::new(Type::Variable(1)), ret: Box::new(Type::Variable(2)), })), }; assert_eq!(Vec::from(func.args()), vec![&Type::Variable(0), &Type::Variable(1)]); assert_eq!(func.returns(), &Type::Variable(2));
With the macros:
let func = arrow![tp!(0), tp!(1), tp!(2)]; if let Type::Arrow(arr) = func { assert_eq!(Vec::from(arr.args()), vec![&tp!(0), &tp!(1)]); assert_eq!(arr.returns(), &tp!(2)); } else { unreachable!() } // we know func is an arrow
Fields
arg: Box<Type>
ret: Box<Type>
Methods
impl Arrow
[src]
fn args(&self) -> VecDeque<&Type>
[src]
Get all arguments to the function, recursing through curried functions.
fn returns(&self) -> &Type
[src]
Get the return type of the function, recursing through curried function returns.
Trait Implementations
impl Debug for Arrow
[src]
impl Clone for Arrow
[src]
fn clone(&self) -> Arrow
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Hash for Arrow
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialEq for Arrow
[src]
fn eq(&self, __arg_0: &Arrow) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Arrow) -> bool
[src]
This method tests for !=
.