Skip to content

Add Clone implementations for managed and managed mutable types. #5750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 54 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
2b07f0f
field renaming
jbclements Mar 12, 2013
556143c
commenting parser
jbclements Mar 8, 2013
f2e47cd
change to parsing using tts
jbclements Mar 6, 2013
a20d1ad
Improve documentation for core::io.
steveklabnik Apr 1, 2013
1d658d9
Improve docs for Core::ReaderUtil.
steveklabnik Apr 2, 2013
948ff60
Typo fix. u8 -> i8
steveklabnik Apr 2, 2013
88e4b5d
install the librust{doc,pkg} host libraries
thestinger Apr 2, 2013
86d5ce5
remove trailing whitespace
steveklabnik Apr 3, 2013
a3e2d6e
Remove excess trailing whitespace.
steveklabnik Apr 3, 2013
e4edfa0
libstd: implement fileinput.
huonw Feb 23, 2013
1e28d8f
libstd: implement io::Reader for fileinput.
huonw Mar 25, 2013
f357a03
auto merge of #5685 : thestinger/rust/build, r=graydon
bors Apr 3, 2013
fea1380
libstd: make fileinput tests pass.
huonw Apr 3, 2013
cb16cd9
auto merge of #5673 : steveklabnik/rust/improve_io_docs, r=catamorphism
bors Apr 3, 2013
26d8b51
auto merge of #5674 : steveklabnik/rust/improve_reader_util_docs, r=c…
bors Apr 3, 2013
0cc9030
auto merge of #5202 : dbaupp/rust/std-fileinput, r=graydon
bors Apr 3, 2013
e2bffb7
Implement Clone for tuples
Apr 3, 2013
afd5cba
auto merge of #5692 : Aatch/rust/tuple-clone, r=thestinger
bors Apr 3, 2013
84e5033
Make bench/noise.rs more idiomatic and 20x faster
bstrie Apr 3, 2013
260d74d
auto merge of #5695 : bstrie/rust/noise, r=thestinger
bors Apr 3, 2013
44029a5
hashmap: rm linear namespace
thestinger Apr 3, 2013
cc148b5
rename Linear{Map,Set} => Hash{Map,Set}
thestinger Apr 3, 2013
c16919d
Removing mut fields from vec.rs, at_vec.rs, str.rs, unstable.rs, and …
Thiez Apr 2, 2013
397a478
Unstable didn't need transmute_mut after all.
Thiez Apr 3, 2013
c4d2b79
Add Clone derivation for std::net::url types.
metajack Apr 3, 2013
6153aae
auto merge of #5559 : jbclements/rust/change-to-tt-based-parsing, r=j…
bors Apr 3, 2013
d79b224
Add information about logging macros to the tutorial.
steveklabnik Apr 3, 2013
34b2336
Fix compiletest on windows
brson Apr 3, 2013
3044f5e
typo fix: na -> an
steveklabnik Apr 3, 2013
5b933ae
auto merge of #5696 : thestinger/rust/hashmap, r=sanxiyn
bors Apr 3, 2013
8dd5a70
Update tut. to not sound like I missed a section
brettcannon Apr 3, 2013
17ab718
auto merge of #5698 : Thiez/rust/de-mutfielding, r=pcwalton
bors Apr 3, 2013
84c296b
auto merge of #5701 : metajack/rust/net-url-clone, r=thestinger
bors Apr 3, 2013
a7f0bfb
One more typo: dubug -> debug
steveklabnik Apr 3, 2013
e2c7a4d
Simple typo fix
ajuckel Apr 4, 2013
783392f
auto merge of #5704 : brson/rust/compiletest, r=luqmana
bors Apr 4, 2013
f064048
Remove a android hack
ILyoan Apr 3, 2013
fac0d9d
Decides main name by target
ILyoan Apr 3, 2013
53232f7
Fix fileinput test fail
ILyoan Apr 4, 2013
af1baa3
auto merge of #5691 : ILyoan/rust/main_name, r=thestinger
bors Apr 4, 2013
aa899c9
auto merge of #5710 : ajuckel/rust/patch-1, r=luqmana
bors Apr 4, 2013
679b1dc
doc: Rewrite task tutorial intro
brson Apr 4, 2013
21de574
auto merge of #5703 : steveklabnik/rust/add_log_docs, r=thestinger
bors Apr 4, 2013
1dc330c
auto merge of #5707 : brettcannon/rust/patch-1, r=thestinger
bors Apr 4, 2013
b5d8224
auto merge of #5713 : brson/rust/tutorial2, r=thestinger
bors Apr 4, 2013
99b156e
mk: mips toolchain config
crabtw Mar 19, 2013
fdf48a7
rt: improve mips backend
crabtw Mar 19, 2013
4f1d8cb
fix mac build and comment on stack size check
crabtw Mar 29, 2013
cb91e91
Tutorial: rename variable to avoid confusion.
Apr 4, 2013
717ed51
auto merge of #5716 : dhardy/rust/master, r=thestinger
bors Apr 4, 2013
2c02aab
Add cell#with_mut_ref for handling mutable references to the content.
metajack Apr 4, 2013
c08fb75
auto merge of #5431 : crabtw/rust/mips-rt, r=brson
bors Apr 4, 2013
babe506
auto merge of #5722 : metajack/rust/cell-with-ref-mut, r=catamorphism
bors Apr 5, 2013
b22a060
Implement Clone for @ and @mut types.
metajack Apr 5, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Implement Clone for @ and @mut types.
The borrowck-borrow-from-expr-block test had to be updated. I'm not sure why
it compiled before since ~int was already clonable.
  • Loading branch information
metajack committed Apr 5, 2013
commit b22a06000d68faf7fe080dc9fd5a2686502d212f
10 changes: 10 additions & 0 deletions src/libcore/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ impl<T:Clone> Clone for ~T {
fn clone(&self) -> ~T { ~(**self).clone() }
}

impl<T:Clone> Clone for @T {
#[inline(always)]
fn clone(&self) -> @T { @(**self).clone() }
}

impl<T:Clone> Clone for @mut T {
#[inline(always)]
fn clone(&self) -> @mut T { @mut (**self).clone() }
}

macro_rules! clone_impl(
($t:ty) => {
impl Clone for $t {
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/borrowck-borrow-from-expr-block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn borrow(x: &int, f: &fn(x: &int)) {
}

fn test1(x: @~int) {
do borrow(&*x.clone()) |p| {
do borrow(&**x.clone()) |p| {
let x_a = ptr::addr_of(&(**x));
assert!((x_a as uint) != ptr::to_uint(p));
assert!(unsafe{*x_a} == *p);
Expand Down
27 changes: 27 additions & 0 deletions src/test/run-pass/clones.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

fn main() {
let a : ~int = ~5i;
let b : ~int = a.clone();

debug!(fmt!("a: %?, b: %?", a, b));

let a : @int = @5i;
let b : @int = a.clone();

debug!(fmt!("a: %?, b: %?", a, b));

let a : @mut int = @mut 5i;
let b : @mut int = a.clone();
*b = 6;

debug!(fmt!("a: %?, b: %?", a, b));
}