Skip to content

Instantly share code, notes, and snippets.

@brson
Created January 19, 2012 08:20
Show Gist options
  • Select an option

  • Save brson/1638716 to your computer and use it in GitHub Desktop.

Select an option

Save brson/1638716 to your computer and use it in GitHub Desktop.

Crate core

Module box

Function ptr_eq

Determine if two shared boxes point to the same object

Arguments:

  • a: @T
  • b: @T

Returns bool

Module char

Utilities for manipulating the char type

Function is_lowercase

Indicates whether a character is in lower case, defined in terms of the Unicode General Category 'Ll'.

Arguments:

  • c: char

Returns bool

Function is_uppercase

Indicates whether a character is in upper case, defined in terms of the Unicode General Category 'Lu'.

Arguments:

  • c: char

Returns bool

Function is_whitespace

Indicates whether a character is whitespace, defined in terms of the Unicode General Categories 'Zs', 'Zl', 'Zp' additional 'Cc'-category control codes in the range [0x09, 0x0d]

Arguments:

  • c: char

Returns bool

Function is_alphanumeric

Indicates whether a character is alphanumeric, defined in terms of the Unicode General Categories 'Nd', 'Nl', 'No' and the Derived Core Property 'Alphabetic'.

Arguments:

  • c: char

Returns bool

Function to_digit

Convert a char to the corresponding digit. Safety note: This function fails if c is not a valid char

Arguments:

  • c: char

Returns u8

Function maybe_digit

Convert a char to the corresponding digit. Returns none when character is not a valid hexadecimal digit.

Arguments:

  • c: char

Returns option::t<u8>

Function to_lower

Convert a char to the corresponding lower case.

Arguments:

  • c: char

Returns char

Function to_upper

Convert a char to the corresponding upper case.

Arguments:

  • c: char

Returns char

Function cmp

Compare two chars.

Arguments:

  • a: char
  • b: char

Returns int

Module float

Module bessel

Module f32

Module f32::consts

Module f64

Module f64::consts

Module int

Module str

Module ptr

Module uint

Module u8

Module u32

Module u64

Module vec

Module vec::unsafe

Module vec::u8

Module bool

Classic Boolean logic reified as ADT

Function not

Negation/Inverse

Arguments:

  • v: t

Returns t

Function and

Conjunction

Arguments:

  • a: t
  • b: t

Returns t

Function or

Disjunction

Arguments:

  • a: t
  • b: t

Returns t

Function xor

Exclusive or, i.e. or(and(a, not(b)), and(not(a), b))

Arguments:

  • a: t
  • b: t

Returns t

Function implies

Implication in the logic, i.e. from a follows b

Arguments:

  • a: t
  • b: t

Returns t

Function eq

true if truth values a and b are indistinguishable in the logic

Arguments:

  • a: t
  • b: t

Returns bool

Function ne

true if truth values a and b are distinguishable in the logic

Arguments:

  • a: t
  • b: t

Returns bool

Function is_true

true if v represents truth in the logic

Arguments:

  • v: t

Returns bool

Function is_false

true if v represents falsehood in the logic

Arguments:

  • v: t

Returns bool

Function from_str

Parse logic value from s

Arguments:

  • s: str

Returns t

Function to_str

Convert v into a string

Arguments:

  • v: t

Returns str

Function all_values

Iterates over all truth values by passing them to blk in an unspecified order

Arguments:

  • blk: fn&(v: t)

Function to_bit

converts truth value to an 8 bit byte

Arguments:

  • v: t

Returns u8

Module unicode

Module unicode::general_category

Module unicode::derived_property

Module either

Module option

Module result

Module tuple

Module ctypes

Definitions useful for C interop

Module math

Module cmath

Module cmath::c_float_targ_consts

Module cmath::c_double_targ_consts

Module sys

Function set_exit_status

Sets the process exit code

Sets the exit code returned by the process if all supervised tasks terminate successfully (without failing). If the current root task fails and is supervised by the scheduler then any user-specified exit status is ignored and the process exits with the default failure status.

Arguments:

  • code: int

Function set_min_stack

Globally set the minimum size, in bytes, of a stack segment

Rust tasks have segmented stacks that are connected in a linked list allowing them to start very small and grow very large. In some situations this can result in poor performance. Calling this function will set the minimum size of all stack segments allocated in the future, for all tasks.

Arguments:

  • size: uint

Module unsafe

Module comm

Communication between tasks

Communication between tasks is facilitated by ports (in the receiving task), and channels (in the sending task). Any number of channels may feed into a single port. Ports and channels may only transmit values of unique types; that is, values that are statically guaranteed to be accessed by a single 'owner' at a time. Unique types include scalars, vectors, strings, and records, tags, tuples and unique boxes (~T) thereof. Most notably, shared boxes (@T) may not be transmitted across channels. Example: let p = comm::port(); task::spawn(comm::chan(p), fn (c: chan) { comm::send(c, "Hello, World"); }); io::println(comm::recv(p));

Function send

Sends data over a channel. The sent data is moved into the channel, whereupon the caller loses access to it.

Arguments:

  • ch: chan<T>
  • data: T

Function port

Constructs a port.

Returns port<T>

Function recv

Receive from a port. If no data is available on the port then the task will block until data becomes available.

Arguments:

  • p: port<T>

Returns T

Function recv_

Receive on a raw port pointer

Arguments:

  • p: *rustrt::rust_port

Returns T

Function chan

Constructs a channel. The channel is bound to the port used to construct it.

Arguments:

  • p: port<T>

Returns chan<T>

Module task

Module logging

Logging

Function console_on

Turns on logging to stdout globally

Function console_off

Turns off logging to stdout globally

Turns off the console unless the user has overridden the runtime environment's logging spec, e.g. by setting the RUST_LOG environment variable

Module extfmt

Module extfmt::ct

Module extfmt::rt

Module core

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