Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
veddan
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
6 ms
·
31.
▲
by
veddan
12y ago
> I really hope that the Rust compiler has some really good error messages explaining what the problem is because I couldn't see what was wrong with this fragment until I read the explanation. They're not always perfect, but in
32.
▲
by
veddan
12y ago
Checked array access is implemented with unsafe code. Actual code implementing the `[]` operator for arrays ("slices"): fn index(&self, &index: &uint) -> &T { assert!(index < self.len());
33.
▲
by
veddan
12y ago
> By avoiding privileged optimizations in the frontend and by giving programmers low-level tools where they need them, Rust empowers library authors to get things done without having to bug the Rust developers themselves to implement the
34.
▲
by
veddan
12y ago
In most cases, you use iterators rather than indexing for x in v.iter_mut() { // do some work with x } or if you need the index for (i, x) in v.iter_mut().enumerate() { // do some work
35.
▲
by
veddan
12y ago
If we take your code and modify it so that the compiler can't just get rid of the array acces, we get: extern crate test; fn main() { let mut v = vec![1i32, 2, 3, 4, 5]; let vlen = v.len(); for i in r
36.
▲
by
veddan
12y ago
Also, the CM-5 moved away from the hypercube topology of the CM-2 to a fat tree.
37.
▲
by
veddan
12y ago
>Rust does not use reference-counting GC. Instead, it has a fairly unique borrow checking system for garbage collection, which not only handles cleaning up memory but also cleaning open sockets, file handlers, etc. There is a generic typ
38.
▲
by
veddan
12y ago
It's not just a matter of the compiler missing optimizations. Some (unsafe, low-level) algorithms have to be written differently (and less efficiently) because of the possibility of unwinding. Disallowed patterns typically look somethi
39.
▲
by
veddan
12y ago
Unwinding through C is undefined behavior, so a Rust function called from C must catch all exceptions and (preferably) return an error code to the C caller.
40.
▲
by
veddan
12y ago
I'm sure a similar argument could be made about many human activities.