mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 02:33:55 +00:00
17 lines
331 B
Rust
17 lines
331 B
Rust
//@ check-pass
|
|
|
|
use std::convert::TryFrom;
|
|
|
|
pub trait FieldElement {
|
|
type Integer: TryFrom<usize, Error = std::num::TryFromIntError>;
|
|
|
|
fn valid_integer_try_from<N>(i: N) -> Result<Self::Integer, ()>
|
|
where
|
|
Self::Integer: TryFrom<N>,
|
|
{
|
|
Self::Integer::try_from(i).map_err(|_| ())
|
|
}
|
|
}
|
|
|
|
fn main() {}
|