Byte-Unit icon indicating copy to clipboard operation
Byte-Unit copied to clipboard

[Feature request] Arithmetic Operations

Open JoshuaVandaele opened this issue 2 years ago • 1 comments

Hey,

I've been finding myself using this crate for a personal project, however a current struggle is to add Bytes together (I currently use get_bytes to addition them), however, it'd be great if we'd be able to simply add those two together:

let byte1 = Byte::from(10)
let byte2 = Byte::from(20)
let byte3 = byte1 + byte2 // Currently doesn't work

JoshuaVandaele avatar Dec 17 '23 14:12 JoshuaVandaele

Every operation should be checked to prevent panic or incorrect result. You can use the add method.

let byte3 = byte1.add(byte2).unwrap();

magiclen avatar Dec 17 '23 16:12 magiclen