File tree Expand file tree Collapse file tree 5 files changed +22
-10
lines changed Expand file tree Collapse file tree 5 files changed +22
-10
lines changed Original file line number Diff line number Diff line change 1
1
---
2
2
refs/heads/master: 7be8f0af0393dcdb077c2f6b1653836fd3fba235
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
- refs/heads/snap-stage3: eacc5d779fe4080dd2b45e035ca2af099b8b906d
4
+ refs/heads/snap-stage3: 9ec19373af8aaad641b39a25fa4ac7bfef513fc2
5
5
refs/heads/try: 502e4c045236682e9728539dc0d2b3d0b237f55c
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
Original file line number Diff line number Diff line change @@ -559,7 +559,7 @@ pub mod raw {
559
559
use core:: raw:: Slice ;
560
560
use core:: ptr:: RawPtr ;
561
561
562
- use string:: String ;
562
+ use string:: { mod , String } ;
563
563
use vec:: Vec ;
564
564
565
565
use MutableSeq ;
@@ -592,11 +592,10 @@ pub mod raw {
592
592
buf
593
593
}
594
594
595
- /// Converts an owned vector of bytes to a new owned string. This assumes
596
- /// that the utf-8-ness of the vector has already been validated
597
- #[ inline]
595
+ /// Deprecated. Replaced by `string::raw::from_utf8`
596
+ #[ deprecated = "Use string::raw::from_utf8" ]
598
597
pub unsafe fn from_utf8_owned ( v : Vec < u8 > ) -> String {
599
- mem :: transmute ( v)
598
+ string :: raw :: from_utf8 ( v)
600
599
}
601
600
602
601
/// Converts a byte to a string.
Original file line number Diff line number Diff line change @@ -570,6 +570,19 @@ impl<S: Str> Add<S, String> for String {
570
570
}
571
571
}
572
572
573
+ pub mod raw {
574
+ use super :: String ;
575
+ use vec:: Vec ;
576
+
577
+ /// Converts a vector of bytes to a new `String` without checking if
578
+ /// it contains valid UTF-8. This is unsafe because it assumes that
579
+ /// the utf-8-ness of the vector has already been validated.
580
+ #[ inline]
581
+ pub unsafe fn from_utf8 ( bytes : Vec < u8 > ) -> String {
582
+ String { vec : bytes }
583
+ }
584
+ }
585
+
573
586
#[ cfg( test) ]
574
587
mod tests {
575
588
use std:: prelude:: * ;
Original file line number Diff line number Diff line change 11
11
// ignore-lexer-test FIXME #15679
12
12
13
13
//! Base64 binary-to-text encoding
14
- use std:: str;
15
14
use std:: fmt;
15
+ use std:: string;
16
16
17
17
/// Available encoding character sets
18
18
pub enum CharacterSet {
@@ -148,7 +148,7 @@ impl<'a> ToBase64 for &'a [u8] {
148
148
}
149
149
150
150
unsafe {
151
- str :: raw:: from_utf8_owned ( v)
151
+ string :: raw:: from_utf8 ( v)
152
152
}
153
153
}
154
154
}
Original file line number Diff line number Diff line change 11
11
// ignore-lexer-test FIXME #15679
12
12
13
13
//! Hex binary-to-text encoding
14
- use std:: str;
15
14
use std:: fmt;
15
+ use std:: string;
16
16
17
17
/// A trait for converting a value to hexadecimal encoding
18
18
pub trait ToHex {
@@ -47,7 +47,7 @@ impl<'a> ToHex for &'a [u8] {
47
47
}
48
48
49
49
unsafe {
50
- str :: raw:: from_utf8_owned ( v)
50
+ string :: raw:: from_utf8 ( v)
51
51
}
52
52
}
53
53
}
You can’t perform that action at this time.
0 commit comments