Skip to content

Commit c1f32b7

Browse files
committed
---
yaml --- r: 224241 b: refs/heads/beta c: e333e6a h: refs/heads/master i: 224239: f03e761 v: v3
1 parent f3a1772 commit c1f32b7

File tree

12 files changed

+1129
-59
lines changed

12 files changed

+1129
-59
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 0eea0f6e907ff8c8a25a10004bede7b4621b50aa
26+
refs/heads/beta: e333e6a0dc60ac200e3e4c61dc0e536bee6b98af
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 938f5d7af401e2d8238522fed4a612943b6e77fd
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/doc/rust.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ a > code {
221221
color: #428BCA;
222222
}
223223

224+
.section-header > a > code {
225+
color: #8D1A38;
226+
}
227+
224228
/* Code highlighting */
225229
pre.rust .kw { color: #8959A8; }
226230
pre.rust .kw-2, pre.rust .prelude-ty { color: #4271AE; }

branches/beta/src/doc/trpl/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* [Iterators](iterators.md)
1717
* [Concurrency](concurrency.md)
1818
* [Error Handling](error-handling.md)
19+
* [Choosing your Guarantees](choosing-your-guarantees.md)
1920
* [FFI](ffi.md)
2021
* [Borrow and AsRef](borrow-and-asref.md)
2122
* [Release Channels](release-channels.md)

branches/beta/src/doc/trpl/choosing-your-guarantees.md

Lines changed: 356 additions & 0 deletions
Large diffs are not rendered by default.

branches/beta/src/libcore/char.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,18 @@ pub fn from_u32(i: u32) -> Option<char> {
8484
if (i > MAX as u32) || (i >= 0xD800 && i <= 0xDFFF) {
8585
None
8686
} else {
87-
Some(unsafe { transmute(i) })
87+
Some(unsafe { from_u32_unchecked(i) })
8888
}
8989
}
9090

91+
/// Converts a `u32` to an `char`, not checking whether it is a valid unicode
92+
/// codepoint.
93+
#[inline]
94+
#[unstable(feature = "char_from_unchecked", reason = "recently added API")]
95+
pub unsafe fn from_u32_unchecked(i: u32) -> char {
96+
transmute(i)
97+
}
98+
9199
/// Converts a number to the character representing it.
92100
///
93101
/// # Return value
@@ -115,12 +123,11 @@ pub fn from_digit(num: u32, radix: u32) -> Option<char> {
115123
panic!("from_digit: radix is too high (maximum 36)");
116124
}
117125
if num < radix {
118-
unsafe {
119-
if num < 10 {
120-
Some(transmute('0' as u32 + num))
121-
} else {
122-
Some(transmute('a' as u32 + num - 10))
123-
}
126+
let num = num as u8;
127+
if num < 10 {
128+
Some((b'0' + num) as char)
129+
} else {
130+
Some((b'a' + num - 10) as char)
124131
}
125132
} else {
126133
None
@@ -318,16 +325,13 @@ impl Iterator for EscapeUnicode {
318325
Some('{')
319326
}
320327
EscapeUnicodeState::Value(offset) => {
321-
let v = match ((self.c as i32) >> (offset * 4)) & 0xf {
322-
i @ 0 ... 9 => '0' as i32 + i,
323-
i => 'a' as i32 + (i - 10)
324-
};
328+
let c = from_digit(((self.c as u32) >> (offset * 4)) & 0xf, 16).unwrap();
325329
if offset == 0 {
326330
self.state = EscapeUnicodeState::RightBrace;
327331
} else {
328332
self.state = EscapeUnicodeState::Value(offset - 1);
329333
}
330-
Some(unsafe { transmute(v) })
334+
Some(c)
331335
}
332336
EscapeUnicodeState::RightBrace => {
333337
self.state = EscapeUnicodeState::Done;

0 commit comments

Comments
 (0)