Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

whentze/to_method

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

7 Commits

Repository files navigation

to_method

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:

  • No dependencies of its own
  • No feature flags
  • No build.rs
  • #![no_std]
  • #![forbid(unsafe_code)]

Regular Into usage

let 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();

With To

use 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();

About

A utility micro-crate for using `Into` more ergonomically.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /