Code Monkey home page Code Monkey logo

trimothy's Introduction

Trimothy

docs.rs changelog
crates.io ci deps.rs
license contributions welcome

Trimothy is a small library that expands on the limited String- and slice-trimming capabilities provided by the standard library.

If any of these methods happened to be introduced into stable Rust in the future, they will simply be removed from here.

This crate is #![no_std]-compatible.

TrimSlice

This trait adds the following basic trimming capabilities to &[u8], Vec<u8>, and Box<[u8]>, similar to those enjoyed by strings.

Method Description
trim Trim leading and trailing (ASCII) whitespace.
trim_start Trim leading (ASCII) whitespace.
trim_end Trim trailing (ASCII) whitespace.

TrimSliceMatches

This trait adds the arbitrary, match-based trimming methods to &[u8], Vec<u8>, and Box<[u8]>:

Method Description
trim_matches Trim arbitrary leading and trailing bytes via callback.
trim_start_matches Trim arbitrary leading bytes via callback.
trim_end_matches Trim arbitrary trailing bytes via callback.

TrimMut

This trait brings mutable trimming support to String, Vec<u8>, and Box<[u8]>.

Method Description
trim_mut Trim leading and trailing whitespace (mutably).
trim_start_mut Trim leading whitespace (mutably).
trim_end_mut Trim trailing whitespace (mutably).

TrimMatchesMut

This trait brings mutable match-based trimming String, Vec<u8>, and Box<[u8]>.

Method Description
trim_matches_mut Trim arbitrary leading and trailing bytes via callback (mutably).
trim_start_matches_mut Trim arbitrary leading bytes via callback (mutably).
trim_end_matches_mut Trim arbitrary trailing bytes via callback (mutably).

NormalizeWhitespace

This trait exposes an iterator over byte/string slice contents that trims the edges and compacts/converts all inner, contiguous spans of whitespace to a single horizontal space.

This trait is implemented for &[u8], &str, and Iterators with u8/char items.

Method Description
normalized_whitespace Return a whitespace-normalizing iterator.
normalized_control_and_whitespace Return a control- and whitespace-normalizing iterator.

Installation

The dependency can be added the normal way:

[dependencies]
trimothy = "0.2"

License

Copyright © 2023 Blobfolio, LLC <[email protected]>

This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <[email protected]>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.

trimothy's People

Contributors

joshstoik1 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.