Crates.io | typoglycemia |
lib.rs | typoglycemia |
version | 1.0.1 |
created_at | 2025-08-26 17:31:15.52396+00 |
updated_at | 2025-08-26 19:22:20.563287+00 |
description | A function to convert text to typoglycemic format |
homepage | https://github.com/kendopunk/typoglycemia-rs |
repository | https://github.com/kendopunk/typoglycemia-rs.git |
max_upload_size | |
id | 1811572 |
size | 43,570 |
Typoglycemia implementation for Rust, with a Leet-speak variant.
The phenomenon known as typoglycemia describes the (unproven) cognitive ability to read a word when the first and last letters are stable, but the intermediate letters are scrambled.
"Adncocrig to a rcheeasrer at Cdmgrbaie Usirveinty, it donse't metatr in waht oerdr the ltertes in a wrod are, the olny itapmrnot tinhg is that the frsit and last leettr be at the right palce. The rest can be a toatl mess and you can siltl read it wuihtot prebolm. Tihs is bsauece the haumn mnid deos not raed ervey letetr by isetlf, but the wrod as a wlohe."
"According to a researcher at Cambridge University, it doesn't matter in what order the letters in a word are, the only important thing is that the first and last letter be at the right place. The rest can be a total mess and you can still read it without problem. This is because the human mind does not read every letter by itself, but the word as a whole."
use typoglycemia::{typoglycemia, typoglycemia_leet};
fn main() {
let s = "It was the best of times, it was the worst of \
times, it was the age of wisdom, it was the age of \
foolishness, it was the epoch of belief, it was the epoch \
of incredulity, it was the season of Light, it was the \
season of Darkness, it was the spring of hope, it was \
the winter of despair...";
let t = typoglycemia(s);
println!("{}", t);
// It was the bset of tiems, it was the wrsot of
// tiems, it was the age of wdsiom, it was the age of
// fssenohilos, it was the epoch of beelif, it was the epoch
// of iledruicnty, it was the seosan of Lhgit, it was the
// saeosn of Dnaserks, it was the sinprg of hpoe, it was
// the wtiner of dpaiser...
let l = typoglycemia_leet(s, 1);
println!("{}", l);
// 1t was th3 83st of tm31s, 1t was th3 wrsot of
// tm31s, 1t was th3 ag3 of wdo1sm, 1t was th3 ag3 of
// fsoslhon31s, 1t was th3 3ocph of 83l13f, 1t was th3 3poch
// of 13c1ltrdnuy, 1t was th3 soas3n of Lhg1t, 1t was th3
// soa3sn of Dkr3nass, 1t was th3 snpr1g of hpo3, 1t was
// th3 w1n3tr of d1p3asr...
let e = typoglycemia(
"Emojis can convey emotions that might be difficult \
to express through text alone. For example, a smiley \
face 😊 can show happiness, while a sad face 😞 can \
express sadness. Emojis can also emphasize certain \
words or phrases. For example, using a thumbs-up emoji👍 \
after a positive statement can reinforce the message. \
It's best to use emojis sparingly to avoid overwhelming \
the reader and maintain clarity.",
);
println!("{}", e);
// Emijos can cvnoey enitooms taht mhigt be dciulfift
// to eseprxs tourhgh text anole. For eamplxe, a simely
// fcae 😊 can sohw hnpaesips, wihle a sad fcae 😞 can
// epexrss sasneds. Eojmis can aslo eihmazspe ciaertn
// wdros or psrheas. For expmlae, using a tubmhs-up emjoi👍
// after a pvtiiose statenemt can rencrfoie the mgsasee.
// It's bset to use eiomjs srpgliany to aovid oeenwlvrmhig
// the reedar and miaiatnn cialrty.
}
$> cargo doc --no-deps --document-private-items
$> cargo test -- --show-output # display some examples