#character #print #string #duration #time #typewriter #hello

print_typewriter

Provides an easy way to print strings on character at a time

5 releases

0.1.4 Feb 8, 2023
0.1.3 Feb 7, 2023
0.1.2 Feb 7, 2023
0.1.1 Feb 7, 2023
0.1.0 Feb 7, 2023

#5 in #typewriter

WTFPL license

14KB
87 lines

Print Typewriter

Simple learning project for a Rust Library that lets you print strings character by character in a configurable way.

Usage

Typing out "hello" with each character taking 10 milliseconds to be printed

use print_typewriter::{char_duration, println_typed};

let duration = char_duration!(default 10.ms);
println_typed!(duration, "hello");

Typing "hello world" with each word being typed instantly and each space taking 250 milliesconds

use print_typewriter::{char_duration, println_typed};

let duration = char_duration!(' '->250.ms);
println_typed!(duration, "hello");

Typing a formatted string, "hello {} world" with spaces taking 250 milliseconds, periods taking 1 second, and everything else taking 90

use print_typewriter::{char_duration, println_typed};

let duration = char_duration!(default 90.ms, ' '->250.ms, '.'->1.s);
let beans = "beans";
println_typed!(duration, "hello {} world", beans);

lib.rs:

This crate provides a simple way to print a string and have each letter take a duration of time to be printed out.

Examples

Typing out "hello" with each character taking 10 milliseconds to be printed

use print_typewriter::{char_duration, println_typed};

let duration = char_duration!(default 10.ms);
println_typed!(duration, "hello");

Typing "hello world" with each word being typed instantly and each space taking 250 milliesconds

use print_typewriter::{char_duration, println_typed};

let duration = char_duration!(' '->250.ms);
println_typed!(duration, "hello world");

Typing a formatted string, "hello {} world" with spaces taking 250 milliseconds, periods taking 1 second, and everything else taking 90

use print_typewriter::{char_duration, println_typed};

let duration = char_duration!(default 90.ms, ' '->250.ms, '.'->1.s);
let beans = "beans";
println_typed!(duration, "hello {} world", beans);

No runtime deps