Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add methods to move ByteStrings underlying bytes
Add methods to move the underlying Vec<u8> for ByteString.
- Loading branch information
1 parent
184c7db
commit d23774d
Showing
4 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
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,17 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
use script::dom::bindings::str::ByteString; | ||
|
||
#[test] | ||
fn test_byte_string_move() { | ||
let mut byte_str = ByteString::new(vec![0x73, 0x65, 0x72, 0x76, 0x6f]); | ||
let mut byte_vec = byte_str.bytes(); | ||
|
||
assert_eq!(byte_vec, "servo".as_bytes()); | ||
assert_eq!(*byte_str, []); | ||
|
||
byte_vec = byte_str.into(); | ||
assert_eq!(byte_vec, Vec::new()); | ||
} |
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