Skip to content

TryFrom is not implemented for some primitive types #43214

Closed
@MageSlayer

Description

@MageSlayer

Hi

It seems strange that not all primitive types support TryFrom trait.
See below

#![feature(try_from)]
use std::convert::TryFrom;
fn main() {
    let u: usize = TryFrom::try_from(10usize).unwrap();
    let u: u16 = TryFrom::try_from(10u16).unwrap();
    let b: bool = TryFrom::try_from(false).unwrap();
    let f: f32 = TryFrom::try_from(1.0f32).unwrap();
    let f: f64 = TryFrom::try_from(1.0).unwrap();
}

Or https://play.rust-lang.org/?gist=fdfc5e5d4bd8a7ea1a9005ab4c850373&version=nightly
Current nightly implements TryFrom only for integers(?)
bool, f32, f64 fail.

Please fix that.

Metadata

Metadata

Labels

C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions