In today's Rust, there are a number of builtin traits (sometimes
called "kinds"): Send
, Freeze
, Share
, and Pod
(in the future,
perhaps Sized
). These are expressed as traits, but they are quite
unlike other traits in certain ways. One way is that they do not have
any methods; instead, implementing a trait like Freeze
indicates
that the type has certain properties (defined below). The biggest
difference, though, is that these traits are not implemented manually
by users. Instead, the compiler decides automatically whether or not a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/js/src/builtin/TypedObject.js b/js/src/builtin/TypedObject.js | |
index 3821665..59ee049 100644 | |
--- a/js/src/builtin/TypedObject.js | |
+++ b/js/src/builtin/TypedObject.js | |
@@ -1430,7 +1430,7 @@ function MapTypedParImplDepth1(inArray, inArrayType, outArrayType, func) { | |
return outArray; | |
function redirect(typedObj, offset) { | |
- if (!InParallelSection() || !outGrainTypeIsTransparent) { | |
+ if (!outGrainTypeIsTransparent || !InParallelSection()) { |
Today, if you do a mutable borrow of a local variable, you lose the ability to write to that variable except through the new reference you just created:
let mut x = 3;
let p = &mut x;
x += 1; // Error
*p += 1; // OK
However, you retain the ability to read the original variable:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<typename K, typename V> | |
class entry { | |
K key; | |
V value; | |
public: | |
entry(K&& key, V&& value) | |
: key(key), value(value) { } | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit a0049922adf1efd3ac0f416f6bf2bea472b08277 | |
Author: Niko Matsakis <niko@alum.mit.edu> | |
Date: Tue Mar 4 10:20:16 2014 -0500 | |
WIP -- new tests, patch | |
diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs | |
index 2ba008b..6a2c4e2 100644 | |
--- a/src/librustc/middle/mem_categorization.rs | |
+++ b/src/librustc/middle/mem_categorization.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 23a1d59063159b233cfb559f77c6149df5be62d6 | |
Author: Niko Matsakis <niko@alum.mit.edu> | |
Date: Fri Mar 7 11:10:14 2014 -0500 | |
WIP nits | |
diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs | |
index a48c640..ad7a418 100644 | |
--- a/src/librustc/middle/trans/callee.rs | |
+++ b/src/librustc/middle/trans/callee.rs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Ord trait | |
A possible Ord trait definition: | |
enum Ordering { | |
LessThan, Equal, GreaterThan | |
} | |
// Defines both a partial and total ordering. | |
// The partial ordering may contain unordered |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn foo<type T>(f: fn() -> ~T) { | |
let y: T; | |
{ | |
let z = f(); | |
y = *z; | |
} | |
// y points into freed memory | |
} | |
compare to: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(managed_boxes)] | |
fn foo<'a>(x: &'a @int) -> &'a int { | |
match x { | |
&ref y => { | |
&**y // Do not expect an error here | |
} | |
} | |
} |
OlderNewer