sample-code: proper type annotations on HEX_LUT, add FIXME for min and max
This commit is contained in:
parent
a188c5b65e
commit
7d98ef87d5
@ -2,7 +2,7 @@
|
|||||||
mod math;
|
mod math;
|
||||||
|
|
||||||
// TODO: casting and/or conversion
|
// TODO: casting and/or conversion
|
||||||
const HEX_LUT: Array = [
|
const HEX_LUT: [char; 16] = [
|
||||||
'0', '1', '2', '3', //
|
'0', '1', '2', '3', //
|
||||||
'4', '5', '6', '7', //
|
'4', '5', '6', '7', //
|
||||||
'8', '9', 'a', 'b', //
|
'8', '9', 'a', 'b', //
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
//! Useful math functions
|
//! Useful math functions
|
||||||
|
|
||||||
|
// FIXME:
|
||||||
|
// These two functions shouldn't actually be polymorphic, but
|
||||||
|
// the AST interpreter doesn't know about type annotations
|
||||||
|
// or operator overloading.
|
||||||
|
#[generic("T")]
|
||||||
pub fn max(a: T, b: T) -> T {
|
pub fn max(a: T, b: T) -> T {
|
||||||
(if a < b { b } else { a })
|
(if a < b { b } else { a })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[generic("T")]
|
||||||
pub fn min(a: T, b: T) -> T {
|
pub fn min(a: T, b: T) -> T {
|
||||||
(if a > b { b } else { a })
|
(if a > b { b } else { a })
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user