diff options
| author | bors <bors@rust-lang.org> | 2015-06-11 16:33:53 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-06-11 16:33:53 +0000 |
| commit | deff2f50a97342c8b2f92a124ded2d2ead7b2996 (patch) | |
| tree | 9309584436728300c3bea072656c65c7f0ad5054 /src | |
| parent | c85f30736913cf42549d8e0fd40049b346b4cec4 (diff) | |
| parent | e50675d549edfcb49f712ee3915155cf1cc8f1a2 (diff) | |
| download | rust-deff2f50a97342c8b2f92a124ded2d2ead7b2996.tar.gz rust-deff2f50a97342c8b2f92a124ded2d2ead7b2996.zip | |
Auto merge of #26212 - Manishearth:rollup, r=Manishearth
- Successful merges: #26181, #26184, #26189, #26191, #26195, #26202 - Failed merges:
Diffstat (limited to 'src')
| -rw-r--r-- | src/doc/complement-lang-faq.md | 10 | ||||
| -rw-r--r-- | src/doc/trpl/closures.md | 50 | ||||
| -rw-r--r-- | src/libcore/iter.rs | 1 | ||||
| -rw-r--r-- | src/libcore/option.rs | 1 | ||||
| -rw-r--r-- | src/librustc_typeck/diagnostics.rs | 8 | ||||
| -rw-r--r-- | src/librustc_unicode/char.rs | 2 |
6 files changed, 34 insertions, 38 deletions
diff --git a/src/doc/complement-lang-faq.md b/src/doc/complement-lang-faq.md index 4d7862788fb..7a3d1940858 100644 --- a/src/doc/complement-lang-faq.md +++ b/src/doc/complement-lang-faq.md @@ -30,15 +30,13 @@ You may also be interested in browsing [trending Rust repositories][github-rust] ## Is anyone using Rust in production? -Currently, Rust is still pre-1.0, and so we don't recommend that you use Rust -in production unless you know exactly what you're getting into. - -That said, there are two production deployments of Rust that we're aware of: +Yes. For example (incomplete): * [OpenDNS](http://labs.opendns.com/2013/10/04/zeromq-helping-us-block-malicious-domains/) * [Skylight](http://skylight.io) - -Let the fact that this is an easily countable number be a warning. +* [wit.ai](https://github.com/wit-ai/witd) +* [Codius](https://codius.org/blog/codius-rust/) +* [MaidSafe](http://maidsafe.net/) ## Does it run on Windows? diff --git a/src/doc/trpl/closures.md b/src/doc/trpl/closures.md index 4479fdb7baa..428897821cf 100644 --- a/src/doc/trpl/closures.md +++ b/src/doc/trpl/closures.md @@ -324,37 +324,34 @@ first, it may seem strange, but we’ll figure it out. Here’s how you’d prob try to return a closure from a function: ```rust,ignore -fn factory() -> (Fn(i32) -> Vec<i32>) { - let vec = vec![1, 2, 3]; +fn factory() -> (Fn(i32) -> i32) { + let num = 5; - |n| vec.push(n) + |x| x + num } let f = factory(); -let answer = f(4); -assert_eq!(vec![1, 2, 3, 4], answer); +let answer = f(1); +assert_eq!(6, answer); ``` This gives us these long, related errors: ```text error: the trait `core::marker::Sized` is not implemented for the type -`core::ops::Fn(i32) -> collections::vec::Vec<i32>` [E0277] -f = factory(); -^ -note: `core::ops::Fn(i32) -> collections::vec::Vec<i32>` does not have a -constant size known at compile-time -f = factory(); -^ -error: the trait `core::marker::Sized` is not implemented for the type -`core::ops::Fn(i32) -> collections::vec::Vec<i32>` [E0277] -factory() -> (Fn(i32) -> Vec<i32>) { - ^~~~~~~~~~~~~~~~~~~~~ -note: `core::ops::Fn(i32) -> collections::vec::Vec<i32>` does not have a constant size known at compile-time -factory() -> (Fn(i32) -> Vec<i32>) { - ^~~~~~~~~~~~~~~~~~~~~ - +`core::ops::Fn(i32) -> i32` [E0277] +fn factory() -> (Fn(i32) -> i32) { + ^~~~~~~~~~~~~~~~ +note: `core::ops::Fn(i32) -> i32` does not have a constant size known at compile-time +fn factory() -> (Fn(i32) -> i32) { + ^~~~~~~~~~~~~~~~ +error: the trait `core::marker::Sized` is not implemented for the type `core::ops::Fn(i32) -> i32` [E0277] +let f = factory(); + ^ +note: `core::ops::Fn(i32) -> i32` does not have a constant size known at compile-time +let f = factory(); + ^ ``` In order to return something from a function, Rust needs to know what @@ -364,16 +361,16 @@ way to give something a size is to take a reference to it, as references have a known size. So we’d write this: ```rust,ignore -fn factory() -> &(Fn(i32) -> Vec<i32>) { - let vec = vec![1, 2, 3]; +fn factory() -> &(Fn(i32) -> i32) { + let num = 5; - |n| vec.push(n) + |x| x + num } let f = factory(); -let answer = f(4); -assert_eq!(vec![1, 2, 3, 4], answer); +let answer = f(1); +assert_eq!(6, answer); ``` But we get another error: @@ -448,7 +445,8 @@ assert_eq!(6, answer); We use a trait object, by `Box`ing up the `Fn`. There’s just one last problem: ```text -error: `num` does not live long enough +error: closure may outlive the current function, but it borrows `num`, +which is owned by the current function [E0373] Box::new(|x| x + num) ^~~~~~~~~~~ ``` diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index b12a1c1ed96..abee61ea9d6 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -3077,6 +3077,7 @@ pub fn empty<T>() -> Empty<T> { } /// An iterator that yields an element exactly once. +#[derive(Clone)] #[unstable(feature="iter_once", reason = "new addition")] pub struct Once<T> { inner: ::option::IntoIter<T> diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 872186c09e2..30ca64028e7 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -865,6 +865,7 @@ impl<'a, A> DoubleEndedIterator for IterMut<'a, A> { impl<'a, A> ExactSizeIterator for IterMut<'a, A> {} /// An iterator over the item contained inside an Option. +#[derive(Clone)] #[stable(feature = "rust1", since = "1.0.0")] pub struct IntoIter<A> { inner: Item<A> } diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index c88e857eae5..d89174295a8 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -586,11 +586,9 @@ struct ListNode { This type cannot have a well-defined size, because it needs to be arbitrarily large (since we would be able to nest `ListNode`s to any depth). Specifically, -``` -size of ListNode = 1 byte for head - + 1 byte for the discriminant of the Option - + size of ListNode -``` + size of `ListNode` = 1 byte for `head` + + 1 byte for the discriminant of the `Option` + + size of `ListNode` One way to fix this is by wrapping `ListNode` in a `Box`, like so: diff --git a/src/librustc_unicode/char.rs b/src/librustc_unicode/char.rs index a8bee00f4a9..946a833b3f8 100644 --- a/src/librustc_unicode/char.rs +++ b/src/librustc_unicode/char.rs @@ -486,7 +486,7 @@ impl char { /// # Return value /// /// Returns an iterator which yields the characters corresponding to the - /// lowercase equivalent of the character. If no conversion is possible then + /// titlecase equivalent of the character. If no conversion is possible then /// an iterator with just the input character is returned. #[unstable(feature = "unicode", reason = "recently added")] #[inline] |
