blob: aee954df4616bf890a173837b4c5331182ab5f1a [file] [log] [blame]
Graydon Hoared1affff2012-12-11 01:32:481// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
Erick Tryzelaarad5c6762013-08-17 15:37:4211use std::cmp::Eq;
Patrick Walton1be40be2013-05-21 00:07:2412use std::num::NumCast;
Brian Anderson78ee8212012-11-28 20:34:3013
Brendan Zabarauskasce6ee7b2013-04-13 16:19:3514pub trait NumExt: Eq + Num + NumCast {}
Brian Anderson78ee8212012-11-28 20:34:3015
Patrick Walton07c3f5c2013-02-27 01:12:0016impl NumExt for f32 {}
17impl NumExt for int {}
Brian Anderson78ee8212012-11-28 20:34:3018
19fn num_eq_one<T:NumExt>() -> T {
Patrick Waltondb518ef2013-05-15 21:10:4220 NumCast::from(1)
Brian Anderson78ee8212012-11-28 20:34:3021}
22
Graydon Hoare89c8ef72013-02-02 03:43:1723pub fn main() {
Brian Anderson78ee8212012-11-28 20:34:3024 num_eq_one::<int>(); // you need to actually use the function to trigger the ICE
25}