Crate dev_bestia_string_utils[][src]

Expand description

dev_bestia_string_utils

Library for string manipulation
repository; version: 0.1.19 date: 2021-10-22 authors: Luciano Bestia

Lines in Rust code Lines in Doc comments Lines in Comments Lines in examples Lines in tests

Motivation

There is always some functions around strings that are used very often.
In Rust I use x.to_string() or x.to_owned() or String::from(x) or format!("{}",x) so much, that it deserves something shorter.
For now my best bet is a macro s!(x). I would much rather have a suffix macro like x.s!(), but that does not exist in Rust yet. It has a small probability that one day they will add it to Rust.

Development

I use cargo-auto for my automation tasks like cargo auto build or cargo auto doc, …

cargo crev reviews and advisory

We live in times of danger with supply chain attacks.
It is recommended to always use cargo-crev
to verify the trustworthiness of each of your dependencies.
Please, spread this info.
You can also read reviews quickly on the web:
https://web.crev.dev/rust-reviews/crates/

open-source free and free as a beer

My open-source projects are free and free as a beer (MIT license).
I just love programming.
But I need also to drink. If you find my projects and tutorials helpful,
please buy me a beer donating on my paypal.
You know the price of a beer in your local bar ;-)
So I can drink a free beer for your health :-)
Na zdravje! Alla salute! Prost! Nazdravlje! 🍻

Macros

short macro s!() instead of &str.to_string or format!(), because that is so common an verbose.
Equivalents: String::new(), x.to_string(), x.to_owned(), format!()

Functions

find str from pos_cursor low level
panics if pos_cursor is incorrect: Check for bugs in calling functions.

return the position after the delimiter or None
Does NOT mutate the pos_cursor, because that is for a higher level logic to decide.

return the position before the delimiter or None
Does NOT mutate the pos_cursor, because that is for a higher level logic to decide.

find and return the range of the first occurrence between start and end delimiters
Success: mutates also the cursor position, so the next find will continue from there
Fail: return None if not found and don’t mutate pos_cursor
I use type Range to avoid references &str and lifetimes. But the programmer can make
the error to apply the range to the wrong vector.

find and return the range of the first occurrence including start and end delimiters
Success: mutates also the cursor position, so the next find will continue from there
Fail: return None if not found and don’t mutate pos_cursor
I use type Range to avoid references &str and lifetimes. But the programmer can make
the error to apply the range to the wrong vector.

returns string between the start end end delimiters without delimiters
and the new cursor position

returns a new String without the delimited text