binary code (renamed, it was mistaken for the crate's binary)
This commit is contained in:
parent
5e078c951d
commit
e1edc611bc
3 changed files with 32 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
#[path = "bin_/bytes.rs"]
|
||||
mod bytes;
|
29
bingus/src/bin_/bytes.rs
Normal file
29
bingus/src/bin_/bytes.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
use std::convert::Infallible;
|
||||
|
||||
use rayon::iter::{IntoParallelIterator, ParallelIterator};
|
||||
|
||||
use crate::{Bendable, Bytes, IntoDataBytes, TryFromDataBytes};
|
||||
|
||||
impl IntoDataBytes for Bytes {
|
||||
fn into_bytes(self) -> Bytes {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFromDataBytes for Bytes {
|
||||
type Error = Infallible;
|
||||
type Format = ();
|
||||
fn try_from_bytes(bytes: Bytes, _: Self::Format) -> Result<Self, Self::Error>
|
||||
where
|
||||
Self: Sized,
|
||||
{
|
||||
Ok(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
impl Bendable for Bytes {
|
||||
type Unit = u8;
|
||||
fn map<F: Fn(&Self::Unit) -> Self::Unit + Sync>(self, f: F) -> Self {
|
||||
self.into_par_iter().map(|e| f(&e)).collect()
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ pub mod img;
|
|||
pub mod snd;
|
||||
pub mod txt;
|
||||
|
||||
pub type Bytes = Vec<u8>;
|
||||
pub(crate) type Bytes = Vec<u8>;
|
||||
|
||||
pub trait Bendable: TryFromDataBytes + IntoDataBytes {
|
||||
type Unit;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue