-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #42609 - brson:beta-next, r=alexcrichton
Beta next - #42521 - #42512 - #42482 - #42481 - #42480 r? @nikomatsakis remember to untag 'beta-nominated' on linked issues
- Loading branch information
Showing
8 changed files
with
128 additions
and
20 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2017 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. | ||
|
||
use std::ops::{Deref, DerefMut}; | ||
|
||
struct CheckedDeref<T, F> { | ||
value: T, | ||
check: F | ||
} | ||
|
||
impl<F: Fn(&T) -> bool, T> Deref for CheckedDeref<T, F> { | ||
type Target = T; | ||
fn deref(&self) -> &T { | ||
assert!((self.check)(&self.value)); | ||
&self.value | ||
} | ||
} | ||
|
||
impl<F: Fn(&T) -> bool, T> DerefMut for CheckedDeref<T, F> { | ||
fn deref_mut(&mut self) -> &mut T { | ||
assert!((self.check)(&self.value)); | ||
&mut self.value | ||
} | ||
} | ||
|
||
|
||
fn main() { | ||
let mut v = CheckedDeref { | ||
value: vec![0], | ||
check: |v: &Vec<_>| !v.is_empty() | ||
}; | ||
v.push(1); | ||
assert_eq!(*v, vec![0, 1]); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2017 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. | ||
|
||
struct Foo<T>(T); | ||
|
||
struct IntoIter<T>(T); | ||
|
||
impl<'a, T: 'a> Iterator for IntoIter<T> { | ||
type Item = (); | ||
|
||
fn next(&mut self) -> Option<()> { | ||
None | ||
} | ||
} | ||
|
||
impl<T> IntoIterator for Foo<T> { | ||
type Item = (); | ||
type IntoIter = IntoIter<T>; | ||
|
||
fn into_iter(self) -> IntoIter<T> { | ||
IntoIter(self.0) | ||
} | ||
} | ||
|
||
fn main() {} |
Submodule cargo
updated
5 files
+27 −25 | Cargo.lock | |
+9 −0 | src/cargo/ops/cargo_rustc/context.rs | |
+2 −3 | src/cargo/util/toml.rs | |
+4 −5 | tests/build.rs | |
+6 −0 | tests/package.rs |