rust/tests/ui/coercion/issue-101066.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
330 B
Rust
Raw Normal View History

2022-08-27 03:42:15 +00:00
// 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() {}