Primitive std::str

str
Expand description
string slice

Implementations

pub fn as_ptr(self) -> raw_ptr

Return a raw_ptr to the beginning of the string slice on the heap

pub fn len(self) -> u64

Return the length of the string slice in bytes

pub fn try_as_str_array(self) -> Option<S>

Attempts to convert the string slice into a string array.

Returns

  • [Option] - Some(str_array) if the lengths of the S str_array type and the string slice’s lengths match. Else None.

Examples

fn foo() {
    let string_slice = "abcd";
    let string_array: str[4] = a.try_as_str_array().unwrap();
}

Trait Implementations

pub fn eq(self, other: Self) -> bool

pub fn neq(self, other: Self) -> bool

Evaluates if two values of the same type are not equal.

Additional Information

This function is inherited when eq() is implemented.

Arguments

  • other: [Self] - The value of the same type.

Returns

  • [bool] - true if the two values are not equal, otherwise false.

Examples

struct MyStruct {
    val: u64,
}

impl PartialEq for MyStruct {
    fn eq(self, other: Self) -> bool {
         self.val == other.val
    }
}

fn foo() {
    let struct1 = MyStruct { val: 10 };
    let struct2 = MyStruct { val: 2 };
    let result = struct1 != struct2;
    assert(result);
}

pub fn abi_encode(self, buffer: Buffer) -> Buffer

pub fn abi_decode(refmut buffer: BufferReader) -> str

pub fn hash(
self,
refmut state: Hasher,
)