File: use_in_generics.rs

package info (click to toggle)
rust-conv 0.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 336 kB
  • sloc: makefile: 2
file content (14 lines) | stat: -rw-r--r-- 299 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! Are conversions easily usable in generic code?
extern crate conv;

use conv::prelude::*;

#[test]
fn test_generic_unwrap() {
    fn do_conv<T, U>(t: T) -> U
    where T: ValueInto<U> {
        t.value_into().unwrap()
    }

    assert_eq!({let x: u8 = do_conv(42i32); x}, 42u8);
}