Skip to content

Instantly share code, notes, and snippets.

@Arachnid
Last active May 16, 2016 11:02
Show Gist options
  • Save Arachnid/c5f5fb42857f9cfb840c4c2211887c2e to your computer and use it in GitHub Desktop.
Save Arachnid/c5f5fb42857f9cfb840c4c2211887c2e to your computer and use it in GitHub Desktop.
// Returns a slice containing the entire string.
function slice(string self) returns (Slice);
// Returns a slice containing the requested byte range of the string.
function slice(string self, int start, int end) returns (Slice);
// Returns a new slice pointing at the same underlying string
function slice(Slice self) returns (Slice);
// Returns a slice containing the requested byte range of the parent slice.
function slice(Slice self, int start, int end) returns (Slice);
// Returns the length in characters of self
function charLen(Slice self) returns (uint);
// Returns the length in bytes of self
function byteLen(Slice self) returns (uint);
// Returns the rune starting at byte index idx
function runeAt(Slice self, int idx) returns (uint32);
// Returns the first rune in self, modifying self to point to the next one.
function nextRune(Slice self) returns (uint32);
// Returns the byte index of the nth rune of the slice.
function runeIdx(Slice self, int n) returns (int);
// Returns the byte index of the first occurrence of `needle` in self, or -1 if not found.
function find(Slice self, Slice needle) returns (int);
// Returns the byte index of the last occurrence of `needle` in self, or -1 if not found.
function rfind(Slice self, Slice needle) returns (int);
// Returns the number of nonoverlapping occurrences of `needle` in self.
function count(Slice self, Slice needle) returns (uint);
// Returns true if the slice starts with `needle`
function startsWith(Slice self, Slice needle) returns (bool);
// Returns true if the slice ends with `needle`
function endsWith(Slice self, Slice needle) returns (bool);
// Returns true if the slice contains `needle`
function contains(Slice self, Slice needle) returns (bool);
// Returns a string consisting of all the slices in the list joined using `self` as a delimiter
function join(Slice self, []Slice parts) returns (string);
// Converts the slice to a (newly allocated) string
function toString(Slice self) returns (string);
// Returns the slice up to the first occurrence of `needle`, and updates `self` to point to the remainder of the string
function tokenize(Slice self, Slice needle) returns (Slice);
// Concatenates two slices, returning a newly allocated string.
function concat(Slice self, Slice other) returns (string);
// Computes the keccac-256 sum of the slice
function sha3(Slice self) returns (bytes32);
@Latrasis
Copy link

Isn't this a bit redundant? Since we can simply do a copy by var x = "foo"; var y = x;?

@Arachnid
Copy link
Author

@Latrasis Which function are you referring to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment