Rust 0.6
-
~2100 changes, numerous bugfixes
-
Syntax changes
- The self type parameter in traits is now spelled
Self
- The
self
parameter in trait and impl methods must now be explicitly named (for example:fn f(&self) { }
). Implicit self is deprecated. - Static methods no longer require the
static
keyword and instead are distinguished by the lack of aself
parameter - Replaced the
Durable
trait with the'static
lifetime - The old closure type syntax with the trailing sigil has been removed in favor of the more consistent leading sigil
super
is a keyword, and may be prefixed to paths- Trait bounds are separated with
+
instead of whitespace - Traits are implemented with
impl Trait for Type
instead ofimpl Type: Trait
- Lifetime syntax is now
&'l foo
instead of&l/foo
- The
export
keyword has finally been removed - The
move
keyword has been removed (see "Semantic changes") - The interior mutability qualifier on vectors,
[mut T]
, has been removed. Use&mut [T]
, etc. mut
is no longer valid in~mut T
. Use inherited mutabilityfail
is no longer a keyword. Usefail!()
assert
is no longer a keyword. Useassert!()
log
is no longer a keyword. usedebug!
, etc.- 1-tuples may be represented as
(T,)
- Struct fields may no longer be
mut
. Use inherited mutability,@mut T
,core::mut
orcore::cell
extern mod { ... }
is no longer valid syntax for foreign function modules. Use extern blocks:extern { ... }
- Newtype enums removed. Use tuple-structs.
- Trait implementations no longer support visibility modifiers
- Pattern matching over vectors improved and expanded
const
renamed tostatic
to correspond to lifetime name, and make room for futurestatic mut
unsafe mutable globals.- Replaced
#[deriving_eq]
with#[deriving(Eq)]
, etc. Clone
implementations can be automatically generated with#[deriving(Clone)]
- Casts to traits must use a pointer sigil, e.g.
@foo as @Bar
instead offoo as Bar
. - Fixed length vector types are now written as
[int, .. 3]
instead of[int * 3]
. - Fixed length vector types can express the length as a constant expression. (ex:
[int, .. GL_BUFFER_SIZE - 2]
)
- The self type parameter in traits is now spelled
-
Semantic changes
- Types with owned pointers or custom destructors move by default, eliminating the
move
keyword - All foreign functions are considered unsafe
- &mut is now unaliasable
- Writes to borrowed @mut pointers are prevented dynamically
- () has size 0
- The name of the main function can be customized using #[main]
- The default type of an inferred closure is &fn instead of @fn
use
statements may no longer be "chained" - they cannot import identifiers imported by previoususe
statementsuse
statements are crate relative, importing from the "top" of the crate by default. Paths may be prefixed withsuper::
orself::
to change the search behavior.- Method visibility is inherited from the implementation declaration
- Structural records have been removed
- Many more types can be used in static items, including enums 'static-lifetime pointers and vectors
- Pattern matching over vectors improved and expanded
- Typechecking of closure types has been overhauled to improve inference and eliminate unsoundness
- Macros leave scope at the end of modules, unless that module is tagged with #[macro_escape]
- Types with owned pointers or custom destructors move by default, eliminating the
-
Libraries
- Added big integers to
std::bigint
- Removed
core::oldcomm
module - Added pipe-based
core::comm
module - Numeric traits have been reorganized under
core::num
vec::slice
finally returns a slicedebug!
and friends don't require a format string, e.g.debug!(Foo)
- Containers reorganized around traits in
core::container
core::dvec
removed,~[T]
is a drop-in replacementcore::send_map
renamed tocore::hashmap
std::map
removed; replaced withcore::hashmap
std::treemap
reimplemented as an owned balanced treestd::deque
andstd::smallintmap
reimplemented as owned containerscore::trie
added as a fast ordered map for integer keys- Set types added to
core::hashmap
,core::trie
andstd::treemap
Ord
split intoOrd
andTotalOrd
.Ord
is still used to overload the comparison operators, whereasTotalOrd
is used by certain container types
- Added big integers to
-
Other
- Replaced the 'cargo' package manager with 'rustpkg'
- Added all-purpose 'rust' tool
rustc --test
now supports benchmarks with the#[bench]
attribute- rustc now attempts to offer spelling suggestions
- Improved support for ARM and Android
- Preliminary MIPS backend
- Improved foreign function ABI implementation for x86, x86_64
- Various memory usage improvements
- Rust code may be embedded in foreign code under limited circumstances
- Inline assembler supported by new asm!() syntax extension.