项目作者: srbdev

项目描述 :
A crate for substring functionality for the str type in Rust
高级语言: Rust
项目地址: git://github.com/srbdev/substr.git
创建时间: 2020-07-19T03:39:40Z
项目社区:https://github.com/srbdev/substr

开源协议:MIT License

下载


substr

Rust

A helper crate for substring functionality for Rust’s str type.

Usage

Add the following to your project’s Cargo.toml to include substr as a dependency from GitHub:

  1. [dependencies]
  2. substr = { git = "https://github.com/srbdev/substr" }

or from crates.io:

  1. [dependencies]
  2. substrs = "0.1.0"


fn firstn(s: &str, n: usize) -> &str

Returns the first nth characters from the input string s.

fn lastn(s: &str, n: usize) -> &str

Returns the last nth characters from the input string s.

fn slice(s: &str, start: usize, end: usize) -> &str

Return the substring of the input string s with indices [start, end).




Note: substr will only work on UTF-8 sequences or may otherwise reference invalid memory or
violate the invariants communicated by the str type.