Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

rust just got 4x more productive [shill thread]

Name: Anonymous 2016-12-16 15:09

Rust designers developed an idiom for concisely propagating errors outwards with a macro called try!:
let file = try!(File::open("file.txt"));
More recently, Rust shipped an even more concise notation for error propagation, the postfix ? operator:
let file = File::open("file.txt")?;

Name: Anonymous 2017-01-19 14:52

>>35
Null references pretty clearly have enough uses to justify their existence. For example, with null references, a linked list node can look like:

typedef struct ll_node {
int val;
struct ll_node *next;
} ll_node;


On a 32-bit platform, that would be eight bytes per node. Without null references, it would become

typedef struct ll_node {
int val;
struct ll_node *next;
bool has_next;
} ll_node;


And since structs are typically aligned based on the alignment of their largest member, that single boolean field would add 4 bytes, or 50%, to the size of each node.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List