Skip to content

Commit

Permalink
to_* convenience methods
Browse files Browse the repository at this point in the history
  • Loading branch information
francesca64 committed Apr 27, 2021
1 parent 2e0140e commit e13a814
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased

# 0.1.5 (2021-04-27)

- Added `to_*` casting convenience methods to `Num`.

# 0.1.4 (2021-04-27)

- Added provided `try_cast` and `cast` convenience methods to `Num`.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "en"
version = "0.1.4"
version = "0.1.5"
authors = ["Brainium Studios LLC"]
edition = "2018"
description = "The easiest numeric traits!"
Expand Down
56 changes: 56 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,62 @@ pub trait Num:
cast(self)
}

fn to_i8(self) -> i8 {
self.cast()
}

fn to_i16(self) -> i16 {
self.cast()
}

fn to_i32(self) -> i32 {
self.cast()
}

fn to_i64(self) -> i64 {
self.cast()
}

fn to_i128(self) -> i128 {
self.cast()
}

fn to_isize(self) -> isize {
self.cast()
}

fn to_u8(self) -> u8 {
self.cast()
}

fn to_u16(self) -> u16 {
self.cast()
}

fn to_u32(self) -> u32 {
self.cast()
}

fn to_u64(self) -> u64 {
self.cast()
}

fn to_u128(self) -> u128 {
self.cast()
}

fn to_usize(self) -> usize {
self.cast()
}

fn to_f32(self) -> f32 {
self.cast()
}

fn to_f64(self) -> f64 {
self.cast()
}

fn two() -> Self {
cast(2)
}
Expand Down

0 comments on commit e13a814

Please sign in to comment.