Skip to main content

Module string

Module string 

Source
Expand description

Safe equivalents of functions declared in C’s string.h header.

Functions§

memchr
Finds c, converted to u8, in buf and returns its suffix, or None if not found.
memchr_mut
Finds c, converted to u8, in buf and returns its mutable suffix, or None if not found.
memcmp
Compares the first n bytes of two memory regions.
strcat
Appends the null-terminated byte string s2 to s1.
strchr
Finds c, converted to i8, in null-terminated s and returns its suffix, or None if not found.
strchr_mut
Finds c, converted to i8, in null-terminated s and returns its mutable suffix, or None if not found.
strcmp
Compares two null-terminated byte strings.
strcpy
Copies the null-terminated byte string s2, including its null byte, into s1.
strcspn
Returns the length of the initial segment of null-terminated s1 containing no bytes from null-terminated s2.
strdup
Duplicates the null-terminated byte string s.
strlen
Returns the number of bytes preceding the first null byte in s.
strncat
Appends at most n bytes from s2 to the null-terminated byte string s1.
strncmp
Compares at most n bytes of two byte strings.
strncpy
Copies at most n bytes from s2 into s1, padding with null bytes when needed.
strndup
Duplicates at most n bytes from s and appends a null byte.
strrchr
Finds the last c, converted to i8, in null-terminated s and returns its suffix, or None if not found.
strrchr_mut
Finds the last c, converted to i8, in null-terminated s and returns its mutable suffix, or None if not found.
strspn
Returns the length of the initial segment of null-terminated s1 containing only bytes from null-terminated s2.
strstr
Finds null-terminated s2 in null-terminated s1 and returns its suffix, or None if not found.
strstr_mut
Finds null-terminated s2 in null-terminated s1 and returns its mutable suffix, or None if not found.