File tree 13 files changed +85
-16
lines changed
13 files changed +85
-16
lines changed Original file line number Diff line number Diff line change 47
47
matrix.os == 'windows-latest' &&
48
48
matrix.rust == 'nightly'
49
49
run : cargo test --test debugger_visualizer --features "url/serde,url/debugger_visualizer" -- --test-threads=1
50
+ - name : Test `no_std` support
51
+ run : cargo test --no-default-features --features=alloc
50
52
51
53
WASM :
52
54
runs-on : ubuntu-latest
Original file line number Diff line number Diff line change @@ -3,12 +3,18 @@ name = "data-url"
3
3
version = " 0.2.0"
4
4
authors = [
" Simon Sapin <[email protected] >" ]
5
5
description = " Processing of data: URL according to WHATWG’s Fetch Standard"
6
+ categories = [" no_std" ]
6
7
repository = " https://github.com/servo/rust-url"
7
8
license = " MIT OR Apache-2.0"
8
9
edition = " 2018"
9
10
autotests = false
10
11
rust-version = " 1.51"
11
12
13
+ [features ]
14
+ default = [" std" ]
15
+ std = [" alloc" ]
16
+ alloc = []
17
+
12
18
[dev-dependencies ]
13
19
tester = " 0.9"
14
20
serde = {version = " 1.0" , features = [" derive" ]}
Original file line number Diff line number Diff line change 1
1
//! <https://infra.spec.whatwg.org/#forgiving-base64-decode>
2
2
3
+ use alloc:: vec:: Vec ;
4
+
3
5
#[ derive( Debug ) ]
4
6
pub struct InvalidBase64 ( InvalidBase64Details ) ;
5
7
Original file line number Diff line number Diff line change 14
14
//! assert_eq!(body, b"Hello World!");
15
15
//! assert!(fragment.is_none());
16
16
//! ```
17
+ #![ no_std]
18
+
19
+ // For forwards compatibility
20
+ #[ cfg( feature = "std" ) ]
21
+ extern crate std as _;
22
+
23
+ #[ macro_use]
24
+ extern crate alloc;
25
+
26
+ #[ cfg( not( feature = "alloc" ) ) ]
27
+ compile_error ! ( "the `alloc` feature must be enabled" ) ;
28
+
29
+ use alloc:: { string:: String , vec:: Vec } ;
17
30
18
31
macro_rules! require {
19
32
( $condition: expr) => {
Original file line number Diff line number Diff line change 1
- use std:: fmt:: { self , Write } ;
2
- use std:: str:: FromStr ;
1
+ use alloc:: { borrow:: ToOwned , string:: String , vec:: Vec } ;
2
+ use core:: fmt:: { self , Write } ;
3
+ use core:: str:: FromStr ;
3
4
4
5
/// <https://mimesniff.spec.whatwg.org/#mime-type-representation>
5
6
#[ derive( Debug , PartialEq , Eq ) ]
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ name = "form_urlencoded"
3
3
version = " 1.1.0"
4
4
authors = [" The rust-url developers" ]
5
5
description = " Parser and serializer for the application/x-www-form-urlencoded syntax, as used by HTML forms."
6
+ categories = [" no_std" ]
6
7
repository = " https://github.com/servo/rust-url"
7
8
license = " MIT OR Apache-2.0"
8
9
edition = " 2018"
@@ -11,5 +12,10 @@ rust-version = "1.51"
11
12
[lib ]
12
13
test = false
13
14
15
+ [features ]
16
+ default = [" std" ]
17
+ std = [" alloc" , " percent-encoding/std" ]
18
+ alloc = [" percent-encoding/alloc" ]
19
+
14
20
[dependencies ]
15
- percent-encoding = { version = " 2.2.0" , path = " ../percent_encoding" }
21
+ percent-encoding = { version = " 2.2.0" , default-features = false , path = " ../percent_encoding" }
Original file line number Diff line number Diff line change 12
12
//!
13
13
//! Converts between a string (such as an URL’s query string)
14
14
//! and a sequence of (name, value) pairs.
15
+ #![ no_std]
15
16
17
+ // For forwards compatibility
18
+ #[ cfg( feature = "std" ) ]
19
+ extern crate std as _;
20
+
21
+ extern crate alloc;
22
+
23
+ #[ cfg( not( feature = "alloc" ) ) ]
24
+ compile_error ! ( "the `alloc` feature must currently be enabled" ) ;
25
+
26
+ use alloc:: borrow:: { Borrow , Cow , ToOwned } ;
27
+ use alloc:: string:: String ;
28
+ use core:: str;
16
29
use percent_encoding:: { percent_decode, percent_encode_byte} ;
17
- use std:: borrow:: { Borrow , Cow } ;
18
- use std:: str;
19
30
20
31
/// Convert a byte string in the `application/x-www-form-urlencoded` syntax
21
32
/// into a iterator of (name, value) pairs.
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ name = "idna"
3
3
version = " 0.3.0"
4
4
authors = [" The rust-url developers" ]
5
5
description = " IDNA (Internationalizing Domain Names in Applications) and Punycode."
6
+ categories = [" no_std" ]
6
7
repository = " https://github.com/servo/rust-url/"
7
8
license = " MIT OR Apache-2.0"
8
9
autotests = false
@@ -12,6 +13,11 @@ rust-version = "1.51"
12
13
[lib ]
13
14
doctest = false
14
15
16
+ [features ]
17
+ default = [" std" ]
18
+ std = [" alloc" , " unicode-bidi/std" , " unicode-normalization/std" ]
19
+ alloc = []
20
+
15
21
[[test ]]
16
22
name = " tests"
17
23
harness = false
@@ -26,8 +32,8 @@ tester = "0.9"
26
32
serde_json = " 1.0"
27
33
28
34
[dependencies ]
29
- unicode-bidi = " 0.3"
30
- unicode-normalization = " 0.1.17 "
35
+ unicode-bidi = { version = " 0.3.10 " , default-features = false , features = [ " hardcoded-data " ] }
36
+ unicode-normalization = { version = " 0.1.22 " , default-features = false }
31
37
32
38
[[bench ]]
33
39
name = " all"
Original file line number Diff line number Diff line change 31
31
//! > This document specifies a mechanism
32
32
//! > that minimizes the impact of this transition for client software,
33
33
//! > allowing client software to access domains that are valid under either system.
34
+ #![ no_std]
35
+
36
+ // For forwards compatibility
37
+ #[ cfg( feature = "std" ) ]
38
+ extern crate std;
39
+
40
+ extern crate alloc;
41
+
42
+ #[ cfg( not( feature = "alloc" ) ) ]
43
+ compile_error ! ( "the `alloc` feature must be enabled" ) ;
34
44
35
45
#[ cfg( test) ]
36
46
#[ macro_use]
37
47
extern crate assert_matches;
38
48
49
+ use alloc:: string:: String ;
50
+
39
51
pub mod punycode;
40
52
mod uts46;
41
53
Original file line number Diff line number Diff line change 13
13
//! `encode_str` and `decode_to_string` provide convenience wrappers
14
14
//! that convert from and to Rust’s UTF-8 based `str` and `String` types.
15
15
16
- use std:: char;
17
- use std:: u32;
16
+ use alloc:: { string:: String , vec:: Vec } ;
17
+ use core:: char;
18
+ use core:: u32;
18
19
19
20
// Bootstring parameters for Punycode
20
21
static BASE : u32 = 36 ;
@@ -168,7 +169,7 @@ impl Decoder {
168
169
}
169
170
170
171
pub ( crate ) struct Decode < ' a > {
171
- base : std :: str:: Chars < ' a > ,
172
+ base : core :: str:: Chars < ' a > ,
172
173
pub ( crate ) insertions : & ' a [ ( usize , char ) ] ,
173
174
inserted : usize ,
174
175
position : usize ,
Original file line number Diff line number Diff line change 11
11
12
12
use self :: Mapping :: * ;
13
13
use crate :: punycode;
14
- use std:: { error:: Error as StdError , fmt} ;
14
+
15
+ use alloc:: string:: String ;
16
+ use core:: fmt;
15
17
use unicode_bidi:: { bidi_class, BidiClass } ;
16
18
use unicode_normalization:: char:: is_combining_mark;
17
19
use unicode_normalization:: { is_nfc, UnicodeNormalization } ;
@@ -70,10 +72,10 @@ fn find_char(codepoint: char) -> &'static Mapping {
70
72
}
71
73
72
74
struct Mapper < ' a > {
73
- chars : std :: str:: Chars < ' a > ,
75
+ chars : core :: str:: Chars < ' a > ,
74
76
config : Config ,
75
77
errors : & ' a mut Errors ,
76
- slice : Option < std :: str:: Chars < ' static > > ,
78
+ slice : Option < core :: str:: Chars < ' static > > ,
77
79
}
78
80
79
81
impl < ' a > Iterator for Mapper < ' a > {
@@ -708,7 +710,8 @@ impl From<Errors> for Result<(), Errors> {
708
710
}
709
711
}
710
712
711
- impl StdError for Errors { }
713
+ #[ cfg( feature = "std" ) ]
714
+ impl std:: error:: Error for Errors { }
712
715
713
716
impl fmt:: Display for Errors {
714
717
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
Original file line number Diff line number Diff line change @@ -3,11 +3,13 @@ name = "percent-encoding"
3
3
version = " 2.2.0"
4
4
authors = [" The rust-url developers" ]
5
5
description = " Percent encoding and decoding"
6
+ categories = [" no_std" ]
6
7
repository = " https://github.com/servo/rust-url/"
7
8
license = " MIT OR Apache-2.0"
8
9
edition = " 2018"
9
10
rust-version = " 1.51"
10
11
11
12
[features ]
12
- default = [" alloc" ]
13
+ default = [" std" ]
14
+ std = [" alloc" ]
13
15
alloc = []
Original file line number Diff line number Diff line change 36
36
//!
37
37
//! assert_eq!(utf8_percent_encode("foo <bar>", FRAGMENT).to_string(), "foo%20%3Cbar%3E");
38
38
//! ```
39
-
40
39
#![ no_std]
40
+
41
+ // For forwards compatibility
42
+ #[ cfg( feature = "std" ) ]
43
+ extern crate std as _;
44
+
41
45
#[ cfg( feature = "alloc" ) ]
42
46
extern crate alloc;
43
47
You can’t perform that action at this time.
0 commit comments