Skip to content

Commit abf0548

Browse files
committed
2 parents 07f807d + 7644ef8 commit abf0548

File tree

20 files changed

+327
-283
lines changed

20 files changed

+327
-283
lines changed

src/doc/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ideas behind Rust.
1919
donated to the Rust project. As the name implies, it teaches you Rust through a
2020
series of small examples.
2121

22-
[rbe]: rustbyexample.com
22+
[rbe]: http://rustbyexample.com/
2323

2424
# Community & Getting Help
2525

src/doc/trpl/ffi.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pub fn uncompress(src: &[u8]) -> Option<Vec<u8>> {
166166
}
167167
```
168168

169-
For reference, the examples used here are also available as an [library on
169+
For reference, the examples used here are also available as a [library on
170170
GitHub](https://github.com/thestinger/rust-snappy).
171171

172172
# Destructors

src/doc/trpl/hello-world.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ We’ll get to the details eventually, you’ll just have to trust us for now.
104104

105105
Next, `"Hello, world!"` is a ‘string’. Strings are a surprisingly complicated
106106
topic in a systems programming language, and this is a ‘statically allocated’
107-
string. If you want to read further about allocation, check out [the stack and
108-
the heap], but you don’t need to right now if you don’t want to. We pass this
109-
string as an argument to `println!`, which prints the string to the screen.
110-
Easy enough!
107+
string. If you want to read further about allocation, check out
108+
[the stack and the heap][allocation], but you don’t need to right now if you
109+
don’t want to. We pass this string as an argument to `println!`, which prints the
110+
string to the screen. Easy enough!
111111

112112
[allocation]: the-stack-and-the-heap.html
113113

src/doc/trpl/installing-rust.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ If not, there are a number of places where you can get help. The easiest is
9090
[the #rust IRC channel on irc.mozilla.org][irc], which you can access through
9191
[Mibbit][mibbit]. Click that link, and you'll be chatting with other Rustaceans
9292
(a silly nickname we call ourselves), and we can help you out. Other great
93-
resources include [the user’s forum][users], and [Stack Overflow][stack
94-
overflow].
93+
resources include [the user’s forum][users], and
94+
[Stack Overflow][stack overflow].
9595

9696
[irc]: irc://irc.mozilla.org/#rust
9797
[mibbit]: http://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust

src/doc/trpl/no-stdlib.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ necessary functionality for writing idiomatic and effective Rust code.
103103
As an example, here is a program that will calculate the dot product of two
104104
vectors provided from C, using idiomatic Rust practices.
105105

106-
```
106+
```ignore
107107
#![feature(lang_items, start, no_std, core, libc)]
108108
#![no_std]
109109

src/liballoc/arc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ pub fn get_mut<T>(this: &mut Arc<T>) -> Option<&mut T> {
274274
// reference to the inner data.
275275
let inner = unsafe { &mut **this._ptr };
276276
Some(&mut inner.data)
277-
}else {
277+
} else {
278278
None
279279
}
280280
}

src/libcore/iter.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,9 @@ pub trait Iterator {
273273
FilterMap { iter: self, f: f }
274274
}
275275

276-
/// Creates an iterator that yields a pair of the value returned by this
277-
/// iterator plus the current index of iteration.
276+
/// Creates an iterator that yields pairs `(i, val)` where `i` is the
277+
/// current index of iteration and `val` is the value returned by the
278+
/// iterator.
278279
///
279280
/// `enumerate` keeps its count as a `usize`. If you want to count by a
280281
/// different sized integer, the `zip` function provides similar
@@ -1129,7 +1130,7 @@ pub trait FromIterator<A> {
11291130
/// Conversion into an `Iterator`
11301131
///
11311132
/// Implementing this trait allows you to use your type with Rust's `for` loop. See
1132-
/// the [module level documentation](../index.html) for more details.
1133+
/// the [module level documentation](index.html) for more details.
11331134
#[stable(feature = "rust1", since = "1.0.0")]
11341135
pub trait IntoIterator {
11351136
/// The type of the elements being iterated

src/libcore/ptr.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
//! Working with unsafe pointers in Rust is uncommon,
1616
//! typically limited to a few patterns.
1717
//!
18-
//! Use the [`null` function](fn.null.html) to create null pointers, and
19-
//! the `is_null` method of the `*const T` type to check for null.
20-
//! The `*const T` type also defines the `offset` method, for pointer math.
18+
//! Use the `null` function to create null pointers, and the `is_null` method
19+
//! of the `*const T` type to check for null. The `*const T` type also defines
20+
//! the `offset` method, for pointer math.
2121
//!
2222
//! # Common ways to create unsafe pointers
2323
//!

src/librustc/metadata/loader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
//! > Dear rustc,
130130
//! >
131131
//! > When you are attempting to load the immediate dependency `crate-name`, I
132-
//! > would like you too assume that the library is located at
132+
//! > would like you to assume that the library is located at
133133
//! > `path/to/the/crate.rlib`, and look nowhere else. Also, please do not
134134
//! > assume that the path I specified has the name `crate-name`.
135135
//!

src/libstd/ffi/c_str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ impl CString {
172172
///
173173
/// This method is equivalent to `new` except that no runtime assertion
174174
/// is made that `v` contains no 0 bytes, and it requires an actual
175-
/// byte vector, not anyhting that can be converted to one with Into.
175+
/// byte vector, not anything that can be converted to one with Into.
176176
#[stable(feature = "rust1", since = "1.0.0")]
177177
pub unsafe fn from_vec_unchecked(mut v: Vec<u8>) -> CString {
178178
v.push(0);

src/libstd/fs.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1099,8 +1099,8 @@ impl PathExt for Path {
10991099
/// Changes the timestamps for a file's last modification and access time.
11001100
///
11011101
/// The file at the path specified will have its last access time set to
1102-
/// `atime` and its modification time set to `mtime`. The times specified should
1103-
/// be in milliseconds.
1102+
/// `accessed` and its modification time set to `modified`. The times specified
1103+
/// should be in milliseconds.
11041104
#[unstable(feature = "fs_time",
11051105
reason = "the argument type of u64 is not quite appropriate for \
11061106
this function and may change if the standard library \

src/libstd/io/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ pub trait Read {
148148
///
149149
/// If the return value of this method is `Ok(n)`, then it must be
150150
/// guaranteed that `0 <= n <= buf.len()`. A nonzero `n` value indicates
151-
/// that the buffer `buf` has ben filled in with `n` bytes of data from this
151+
/// that the buffer `buf` has been filled in with `n` bytes of data from this
152152
/// source. If `n` is `0`, then it can indicate one of two scenarios:
153153
///
154154
/// 1. This reader has reached its "end of file" and will likely no longer

src/libstd/net/addr.rs

+1-258
Original file line numberDiff line numberDiff line change
@@ -461,264 +461,7 @@ mod tests {
461461
use io;
462462
use net::*;
463463
use net::Ipv6MulticastScope::*;
464-
465-
#[test]
466-
fn test_from_str_ipv4() {
467-
assert_eq!(Ok(Ipv4Addr::new(127, 0, 0, 1)), "127.0.0.1".parse());
468-
assert_eq!(Ok(Ipv4Addr::new(255, 255, 255, 255)), "255.255.255.255".parse());
469-
assert_eq!(Ok(Ipv4Addr::new(0, 0, 0, 0)), "0.0.0.0".parse());
470-
471-
// out of range
472-
let none: Option<Ipv4Addr> = "256.0.0.1".parse().ok();
473-
assert_eq!(None, none);
474-
// too short
475-
let none: Option<Ipv4Addr> = "255.0.0".parse().ok();
476-
assert_eq!(None, none);
477-
// too long
478-
let none: Option<Ipv4Addr> = "255.0.0.1.2".parse().ok();
479-
assert_eq!(None, none);
480-
// no number between dots
481-
let none: Option<Ipv4Addr> = "255.0..1".parse().ok();
482-
assert_eq!(None, none);
483-
}
484-
485-
#[test]
486-
fn test_from_str_ipv6() {
487-
assert_eq!(Ok(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0)), "0:0:0:0:0:0:0:0".parse());
488-
assert_eq!(Ok(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)), "0:0:0:0:0:0:0:1".parse());
489-
490-
assert_eq!(Ok(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)), "::1".parse());
491-
assert_eq!(Ok(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0)), "::".parse());
492-
493-
assert_eq!(Ok(Ipv6Addr::new(0x2a02, 0x6b8, 0, 0, 0, 0, 0x11, 0x11)),
494-
"2a02:6b8::11:11".parse());
495-
496-
// too long group
497-
let none: Option<Ipv6Addr> = "::00000".parse().ok();
498-
assert_eq!(None, none);
499-
// too short
500-
let none: Option<Ipv6Addr> = "1:2:3:4:5:6:7".parse().ok();
501-
assert_eq!(None, none);
502-
// too long
503-
let none: Option<Ipv6Addr> = "1:2:3:4:5:6:7:8:9".parse().ok();
504-
assert_eq!(None, none);
505-
// triple colon
506-
let none: Option<Ipv6Addr> = "1:2:::6:7:8".parse().ok();
507-
assert_eq!(None, none);
508-
// two double colons
509-
let none: Option<Ipv6Addr> = "1:2::6::8".parse().ok();
510-
assert_eq!(None, none);
511-
}
512-
513-
#[test]
514-
fn test_from_str_ipv4_in_ipv6() {
515-
assert_eq!(Ok(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 49152, 545)),
516-
"::192.0.2.33".parse());
517-
assert_eq!(Ok(Ipv6Addr::new(0, 0, 0, 0, 0, 0xFFFF, 49152, 545)),
518-
"::FFFF:192.0.2.33".parse());
519-
assert_eq!(Ok(Ipv6Addr::new(0x64, 0xff9b, 0, 0, 0, 0, 49152, 545)),
520-
"64:ff9b::192.0.2.33".parse());
521-
assert_eq!(Ok(Ipv6Addr::new(0x2001, 0xdb8, 0x122, 0xc000, 0x2, 0x2100, 49152, 545)),
522-
"2001:db8:122:c000:2:2100:192.0.2.33".parse());
523-
524-
// colon after v4
525-
let none: Option<Ipv4Addr> = "::127.0.0.1:".parse().ok();
526-
assert_eq!(None, none);
527-
// not enough groups
528-
let none: Option<Ipv6Addr> = "1.2.3.4.5:127.0.0.1".parse().ok();
529-
assert_eq!(None, none);
530-
// too many groups
531-
let none: Option<Ipv6Addr> = "1.2.3.4.5:6:7:127.0.0.1".parse().ok();
532-
assert_eq!(None, none);
533-
}
534-
535-
#[test]
536-
fn test_from_str_socket_addr() {
537-
assert_eq!(Ok(sa4(Ipv4Addr::new(77, 88, 21, 11), 80)),
538-
"77.88.21.11:80".parse());
539-
assert_eq!(Ok(sa6(Ipv6Addr::new(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 53)),
540-
"[2a02:6b8:0:1::1]:53".parse());
541-
assert_eq!(Ok(sa6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0x7F00, 1), 22)),
542-
"[::127.0.0.1]:22".parse());
543-
544-
// without port
545-
let none: Option<SocketAddr> = "127.0.0.1".parse().ok();
546-
assert_eq!(None, none);
547-
// without port
548-
let none: Option<SocketAddr> = "127.0.0.1:".parse().ok();
549-
assert_eq!(None, none);
550-
// wrong brackets around v4
551-
let none: Option<SocketAddr> = "[127.0.0.1]:22".parse().ok();
552-
assert_eq!(None, none);
553-
// port out of range
554-
let none: Option<SocketAddr> = "127.0.0.1:123456".parse().ok();
555-
assert_eq!(None, none);
556-
}
557-
558-
#[test]
559-
fn ipv6_addr_to_string() {
560-
// ipv4-mapped address
561-
let a1 = Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0xc000, 0x280);
562-
assert_eq!(a1.to_string(), "::ffff:192.0.2.128");
563-
564-
// ipv4-compatible address
565-
let a1 = Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0xc000, 0x280);
566-
assert_eq!(a1.to_string(), "::192.0.2.128");
567-
568-
// v6 address with no zero segments
569-
assert_eq!(Ipv6Addr::new(8, 9, 10, 11, 12, 13, 14, 15).to_string(),
570-
"8:9:a:b:c:d:e:f");
571-
572-
// reduce a single run of zeros
573-
assert_eq!("ae::ffff:102:304",
574-
Ipv6Addr::new(0xae, 0, 0, 0, 0, 0xffff, 0x0102, 0x0304).to_string());
575-
576-
// don't reduce just a single zero segment
577-
assert_eq!("1:2:3:4:5:6:0:8",
578-
Ipv6Addr::new(1, 2, 3, 4, 5, 6, 0, 8).to_string());
579-
580-
// 'any' address
581-
assert_eq!("::", Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0).to_string());
582-
583-
// loopback address
584-
assert_eq!("::1", Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1).to_string());
585-
586-
// ends in zeros
587-
assert_eq!("1::", Ipv6Addr::new(1, 0, 0, 0, 0, 0, 0, 0).to_string());
588-
589-
// two runs of zeros, second one is longer
590-
assert_eq!("1:0:0:4::8", Ipv6Addr::new(1, 0, 0, 4, 0, 0, 0, 8).to_string());
591-
592-
// two runs of zeros, equal length
593-
assert_eq!("1::4:5:0:0:8", Ipv6Addr::new(1, 0, 0, 4, 5, 0, 0, 8).to_string());
594-
}
595-
596-
#[test]
597-
fn ipv4_to_ipv6() {
598-
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x1234, 0x5678),
599-
Ipv4Addr::new(0x12, 0x34, 0x56, 0x78).to_ipv6_mapped());
600-
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0x1234, 0x5678),
601-
Ipv4Addr::new(0x12, 0x34, 0x56, 0x78).to_ipv6_compatible());
602-
}
603-
604-
#[test]
605-
fn ipv6_to_ipv4() {
606-
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0xffff, 0x1234, 0x5678).to_ipv4(),
607-
Some(Ipv4Addr::new(0x12, 0x34, 0x56, 0x78)));
608-
assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0x1234, 0x5678).to_ipv4(),
609-
Some(Ipv4Addr::new(0x12, 0x34, 0x56, 0x78)));
610-
assert_eq!(Ipv6Addr::new(0, 0, 1, 0, 0, 0, 0x1234, 0x5678).to_ipv4(),
611-
None);
612-
}
613-
614-
#[test]
615-
fn ipv4_properties() {
616-
fn check(octets: &[u8; 4], unspec: bool, loopback: bool,
617-
private: bool, link_local: bool, global: bool,
618-
multicast: bool, broadcast: bool, documentation: bool) {
619-
let ip = Ipv4Addr::new(octets[0], octets[1], octets[2], octets[3]);
620-
assert_eq!(octets, &ip.octets());
621-
622-
assert_eq!(ip.is_unspecified(), unspec);
623-
assert_eq!(ip.is_loopback(), loopback);
624-
assert_eq!(ip.is_private(), private);
625-
assert_eq!(ip.is_link_local(), link_local);
626-
assert_eq!(ip.is_global(), global);
627-
assert_eq!(ip.is_multicast(), multicast);
628-
assert_eq!(ip.is_broadcast(), broadcast);
629-
assert_eq!(ip.is_documentation(), documentation);
630-
}
631-
632-
// address unspec loopbk privt linloc global multicast brdcast doc
633-
check(&[0, 0, 0, 0], true, false, false, false, true, false, false, false);
634-
check(&[0, 0, 0, 1], false, false, false, false, true, false, false, false);
635-
check(&[1, 0, 0, 0], false, false, false, false, true, false, false, false);
636-
check(&[10, 9, 8, 7], false, false, true, false, false, false, false, false);
637-
check(&[127, 1, 2, 3], false, true, false, false, false, false, false, false);
638-
check(&[172, 31, 254, 253], false, false, true, false, false, false, false, false);
639-
check(&[169, 254, 253, 242], false, false, false, true, false, false, false, false);
640-
check(&[192, 168, 254, 253], false, false, true, false, false, false, false, false);
641-
check(&[224, 0, 0, 0], false, false, false, false, true, true, false, false);
642-
check(&[239, 255, 255, 255], false, false, false, false, true, true, false, false);
643-
check(&[255, 255, 255, 255], false, false, false, false, false, false, true, false);
644-
check(&[198, 51, 100, 0], false, false, false, false, false, false, false, true);
645-
}
646-
647-
#[test]
648-
fn ipv6_properties() {
649-
fn check(str_addr: &str, unspec: bool, loopback: bool,
650-
unique_local: bool, global: bool,
651-
u_link_local: bool, u_site_local: bool, u_global: bool,
652-
m_scope: Option<Ipv6MulticastScope>) {
653-
let ip: Ipv6Addr = str_addr.parse().unwrap();
654-
assert_eq!(str_addr, ip.to_string());
655-
656-
assert_eq!(ip.is_unspecified(), unspec);
657-
assert_eq!(ip.is_loopback(), loopback);
658-
assert_eq!(ip.is_unique_local(), unique_local);
659-
assert_eq!(ip.is_global(), global);
660-
assert_eq!(ip.is_unicast_link_local(), u_link_local);
661-
assert_eq!(ip.is_unicast_site_local(), u_site_local);
662-
assert_eq!(ip.is_unicast_global(), u_global);
663-
assert_eq!(ip.multicast_scope(), m_scope);
664-
assert_eq!(ip.is_multicast(), m_scope.is_some());
665-
}
666-
667-
// unspec loopbk uniqlo global unill unisl uniglo mscope
668-
check("::",
669-
true, false, false, true, false, false, true, None);
670-
check("::1",
671-
false, true, false, false, false, false, false, None);
672-
check("::0.0.0.2",
673-
false, false, false, true, false, false, true, None);
674-
check("1::",
675-
false, false, false, true, false, false, true, None);
676-
check("fc00::",
677-
false, false, true, false, false, false, false, None);
678-
check("fdff:ffff::",
679-
false, false, true, false, false, false, false, None);
680-
check("fe80:ffff::",
681-
false, false, false, false, true, false, false, None);
682-
check("febf:ffff::",
683-
false, false, false, false, true, false, false, None);
684-
check("fec0::",
685-
false, false, false, false, false, true, false, None);
686-
check("ff01::",
687-
false, false, false, false, false, false, false, Some(InterfaceLocal));
688-
check("ff02::",
689-
false, false, false, false, false, false, false, Some(LinkLocal));
690-
check("ff03::",
691-
false, false, false, false, false, false, false, Some(RealmLocal));
692-
check("ff04::",
693-
false, false, false, false, false, false, false, Some(AdminLocal));
694-
check("ff05::",
695-
false, false, false, false, false, false, false, Some(SiteLocal));
696-
check("ff08::",
697-
false, false, false, false, false, false, false, Some(OrganizationLocal));
698-
check("ff0e::",
699-
false, false, false, true, false, false, false, Some(Global));
700-
}
701-
702-
fn tsa<A: ToSocketAddrs>(a: A) -> Result<Vec<SocketAddr>, String> {
703-
match a.to_socket_addrs() {
704-
Ok(a) => Ok(a.collect()),
705-
Err(e) => Err(e.to_string()),
706-
}
707-
}
708-
709-
#[test]
710-
fn to_socket_addr_socketaddr() {
711-
let a = sa4(Ipv4Addr::new(77, 88, 21, 11), 12345);
712-
assert_eq!(Ok(vec![a]), tsa(a));
713-
}
714-
715-
fn sa4(a: Ipv4Addr, p: u16) -> SocketAddr {
716-
SocketAddr::V4(SocketAddrV4::new(a, p))
717-
}
718-
719-
fn sa6(a: Ipv6Addr, p: u16) -> SocketAddr {
720-
SocketAddr::V6(SocketAddrV6::new(a, p, 0, 0))
721-
}
464+
use net::test::{tsa, sa6, sa4};
722465

723466
#[test]
724467
fn to_socket_addr_ipaddr_u16() {

0 commit comments

Comments
 (0)