pub struct Colors<W> { /* private fields */ }
Expand description
Colors writable type characters with the ascii rainbow
You can use this any type that requires a io::Write
type
§examples
Write direcly to stdout
use std::io::{self, Write};
write!(
&mut rainbowcoat::Colors::new(io::stdout()),
"hello rainbow"
);
A convenience function makes this common case even easier
use std::io::Write;
write!(
&mut rainbowcoat::stdout(),
"hello rainbow"
);
Implementations§
Source§impl<W> Colors<W>
impl<W> Colors<W>
Sourcepub fn new(wrapped: W) -> Self
pub fn new(wrapped: W) -> Self
Creates a new Colors
instance with default spread of 3.0
,
frequency of 0.1
and seed valud of 0.0
Sourcepub fn configure(wrapped: W, spread: f64, frequency: f64, seed: f64) -> Self
pub fn configure(wrapped: W, spread: f64, frequency: f64, seed: f64) -> Self
Creates a more configurable instance with provided params
Examples found in repository?
examples/coat.rs (line 6)
4fn run() -> io::Result<()> {
5 write!(
6 &mut rainbowcoat::Colors::configure(io::stdout(), 2.0, 0.4, 0.0),
7 r" _
8 ( |
9 |
10 __,--./|.--,__
11 .` \ \ / / `.
12 .` \ | / `.
13 / / ^|^ \ \
14 / / | |o | \ \
15 /===/ | | | \===\
16 /___/ | |o | \___\
17 | | |
18 | |o |
19 | | |
20 | |o |
21 | | |
22 | |o |
23 |_____/\_____|
24"
25 )?;
26 Ok(())
27}
Trait Implementations§
Source§impl<W: Write> Write for Colors<W>
impl<W: Write> Write for Colors<W>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Writes a buffer into this writer, returning how many bytes were written. Read more
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Flushes this output stream, ensuring that all intermediately buffered
contents reach their destination. Read more
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations§
impl<W> Freeze for Colors<W>where
W: Freeze,
impl<W> RefUnwindSafe for Colors<W>where
W: RefUnwindSafe,
impl<W> Send for Colors<W>where
W: Send,
impl<W> Sync for Colors<W>where
W: Sync,
impl<W> Unpin for Colors<W>where
W: Unpin,
impl<W> UnwindSafe for Colors<W>where
W: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more