| Crates.io | to_method |
| lib.rs | to_method |
| version | 1.1.0 |
| created_at | 2021-04-25 14:02:36.455938+00 |
| updated_at | 2021-05-17 18:56:36.660611+00 |
| description | A utility micro-crate for using Into more ergonomically. |
| homepage | https://github.com/whentze/to_method |
| repository | https://github.com/whentze/to_method |
| max_upload_size | |
| id | 389292 |
| size | 12,261 |
A utility micro-crate for using Into more ergonomically.
It exposes a To extension trait with a .to() method
which you can use to invoke Into::into
while specifying the target type and without having to abandon method-call syntax.
Being a micro-crate, it tries to be as nice of a dependency as possible and has:
build.rs#![no_std]#![forbid(unsafe_code)]Into usagelet x : u8 = 5;
// The type parameter is on `Into`, not on `Into::into`,
// so we need to do it like this:
let y = Into::<u16>::into(x);
// Depending on context, inference can make this work though:
let z : u32 = y.into();
Touse to_method::To as _;
let x : u8 = 5;
// The type parameter is on the `to` method, so this works:
let y = x.to::<u16>();
// And you can still rely on inference as well:
let z : u32 = y.to();