Struct polytype::Arrow
[−]
[src]
pub struct Arrow { pub arg: Type, pub ret: Type, }
A curried function.
Examples
use polytype::{Type, Arrow}; let func = Arrow{ arg: Type::Variable(0), ret: Type::Arrow(Box::new(Arrow{ arg: Type::Variable(1), ret: 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: Type
ret: Type
Methods
impl Arrow
[src]
pub fn args(&self) -> VecDeque<&Type>
[src]
Get all arguments to the function, recursing through curried functions.
pub fn returns(&self) -> &Type
[src]
Get the return type of the function, recursing through curried function returns.
Trait Implementations
impl From<Arrow> for Type
[src]
impl Debug for Arrow
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
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 !=
.