All Projects → japaric → cast.rs

japaric / cast.rs

Licence: Apache-2.0, MIT licenses found Licenses found Apache-2.0 LICENSE-APACHE MIT LICENSE-MIT
Machine scalar casting that meets your expectations

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to cast.rs

alloc-cortex-m
A heap allocator for Cortex-M processors
Stars: ✭ 139 (+98.57%)
Mutual labels:  no-std
m
Deprecated in favor of the libm crate.
Stars: ✭ 27 (-61.43%)
Mutual labels:  no-std
metric
This library provides zero-cost dimensional analysis for safe, unit-aware numeric computations in Rust.
Stars: ✭ 23 (-67.14%)
Mutual labels:  no-std
WebScreenVR
WebScreenVR enhance your workspace while in Virtual Reality, allowing you to cast your screen and different applications around you in a 3D environment.
Stars: ✭ 53 (-24.29%)
Mutual labels:  cast
lexical cast
General literal text conversions, such as an int represented as a string, or vice versa
Stars: ✭ 23 (-67.14%)
Mutual labels:  cast
casita
A macOS menubar app to control media playing on your Google Cast enabled devices. 🏡
Stars: ✭ 22 (-68.57%)
Mutual labels:  cast
register-rs
Unified interface for type-safe MMIO and CPU register access in Rust
Stars: ✭ 48 (-31.43%)
Mutual labels:  no-std
shellcast
Shellcasting client and server
Stars: ✭ 26 (-62.86%)
Mutual labels:  cast
m4vga-rs
VGA-style video output for STM32F4 processors, in Rust
Stars: ✭ 122 (+74.29%)
Mutual labels:  no-std
core2
The bare essentials of std::io for use in no_std. Alloc support is optional.
Stars: ✭ 67 (-4.29%)
Mutual labels:  no-std
fixedvec-rs
Heapless vector implementation for Rust
Stars: ✭ 39 (-44.29%)
Mutual labels:  no-std
vlitejs
🦋 vLitejs is a fast and lightweight Javascript library for customizing video and audio player in Javascript with a minimalist theme (HTML5, Youtube, Vimeo, Dailymotion)
Stars: ✭ 162 (+131.43%)
Mutual labels:  cast
semval
Semantic validation for Rust
Stars: ✭ 77 (+10%)
Mutual labels:  no-std
docker-airconnect
This is a dockerized version of AirConnect (https://github.com/philippe44/AirConnect) which bridges AirPlay with Sonos and the Google Cast protocol.
Stars: ✭ 24 (-65.71%)
Mutual labels:  cast
restricted-sparse-merkle-tree
An optimized sparse merkle tree.
Stars: ✭ 47 (-32.86%)
Mutual labels:  no-std
punchtop
A power hour written in rust with Chromecast support
Stars: ✭ 26 (-62.86%)
Mutual labels:  cast
vcell
Just like `Cell` but with volatile read / write operations
Stars: ✭ 16 (-77.14%)
Mutual labels:  no-std
chromecast-mqtt-connector
Make your Chromecast devices discoverable and controllable via MQTT.
Stars: ✭ 40 (-42.86%)
Mutual labels:  cast
undo
A undo-redo library.
Stars: ✭ 38 (-45.71%)
Mutual labels:  no-std
balena-rpiplay
Turn a Raspberry Pi into an Airplay server using RPiPlay to enable screen mirroring on tvs, monitors and projectors.
Stars: ✭ 1,341 (+1815.71%)
Mutual labels:  cast

crates.io crates.io

cast

Ergonomic, checked cast functions for primitive types

extern crate cast;

// `u8` and `u16` are checked cast functions, use them to cast from any numeric
// primitive to `u8`/`u16` respectively
use cast::{u8, u16, Error};

// Infallible operations, like integer promotion, are equivalent to a normal
// cast with `as`
assert_eq!(u16(0u8), 0u16);

// Everything else will return a `Result` depending on the success of the
// operation
assert_eq!(u8(0u16), Ok(0u8));
assert_eq!(u8(256u16), Err(Error::Overflow));
assert_eq!(u8(-1i8), Err(Error::Underflow));
assert_eq!(u8(1. / 0.), Err(Error::Infinite));
assert_eq!(u8(0. / 0.), Err(Error::NaN));

API docs

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].