Unsafe operations

Function buf_as_slice

fn buf_as_slice<T>(buf: *u8, len: uint, f: &fn(v: &str) -> T) -> T

Form a slice from a *u8 buffer of the given length without copying.

Function from_buf

fn from_buf(buf: *u8) -> ~str

Create a Rust string from a null-terminated *u8 buffer

Function from_buf_len

fn from_buf_len(buf: *const u8, len: uint) -> ~str

Create a Rust string from a *u8 buffer of the given length

Function from_byte

fn from_byte(u: u8) -> ~str

Converts a byte to a string.

Function from_bytes

fn from_bytes(v: &[const u8]) -> ~str

Converts a vector of bytes to a string.

Function from_c_str

fn from_c_str(c_str: *libc::c_char) -> ~str

Create a Rust string from a null-terminated C string

Function from_c_str_len

fn from_c_str_len(c_str: *libc::c_char, len: uint) -> ~str

Create a Rust string from a *c_char buffer of the given length

Function pop_byte

fn pop_byte(s: &mut ~str) -> u8

Removes the last byte from a string and returns it. (Not UTF-8 safe).

Function push_byte

fn push_byte(s: &mut ~str, b: u8)

Appends a byte to a string. (Not UTF-8 safe).

Function push_bytes

fn push_bytes(s: &mut ~str, bytes: &[u8])

Appends a vector of bytes to a string. (Not UTF-8 safe).

Function set_len

fn set_len(v: &mut ~str, new_len: uint)

Sets the length of the string and adds the null terminator

Function shift_byte

fn shift_byte(s: &mut ~str) -> u8

Removes the first byte from a string and returns it. (Not UTF-8 safe).

Function slice_bytes

fn slice_bytes(s: &str, begin: uint, end: uint) -> ~str

Takes a bytewise (not UTF-8) slice from a string.

Returns the substring from [begin..end).

Failure

If begin is greater than end. If end is greater than the length of the string.

Function view_bytes

fn view_bytes(s: &str, begin: uint, end: uint) -> &str

Takes a bytewise (not UTF-8) view from a string.

Returns the substring from [begin..end).

Failure

If begin is greater than end. If end is greater than the length of the string.