File tree Expand file tree Collapse file tree 4 files changed +31
-9
lines changed Expand file tree Collapse file tree 4 files changed +31
-9
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ name = "idna"
33version = " 0.3.0"
44authors = [" The rust-url developers" ]
55description = " IDNA (Internationalizing Domain Names in Applications) and Punycode."
6+ categories = [" no_std" ]
67repository = " https://github.com/servo/rust-url/"
78license = " MIT OR Apache-2.0"
89autotests = false
@@ -12,6 +13,11 @@ rust-version = "1.51"
1213[lib ]
1314doctest = false
1415
16+ [features ]
17+ default = [" std" ]
18+ std = [" alloc" , " unicode-bidi/std" , " unicode-normalization/std" ]
19+ alloc = []
20+
1521[[test ]]
1622name = " tests"
1723harness = false
@@ -26,8 +32,8 @@ tester = "0.9"
2632serde_json = " 1.0"
2733
2834[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 }
3137
3238[[bench ]]
3339name = " all"
Original file line number Diff line number Diff line change 3131//! > This document specifies a mechanism
3232//! > that minimizes the impact of this transition for client software,
3333//! > 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 currently be enabled" ) ;
3444
3545#[ cfg( test) ]
3646#[ macro_use]
3747extern crate assert_matches;
3848
49+ use alloc:: string:: String ;
50+
3951pub mod punycode;
4052mod uts46;
4153
Original file line number Diff line number Diff line change 1313//! `encode_str` and `decode_to_string` provide convenience wrappers
1414//! that convert from and to Rust’s UTF-8 based `str` and `String` types.
1515
16- use std:: char;
17- use std:: u32;
16+ use alloc:: { string:: String , vec:: Vec } ;
17+ use core:: char;
18+ use core:: u32;
1819
1920// Bootstring parameters for Punycode
2021static BASE : u32 = 36 ;
@@ -168,7 +169,7 @@ impl Decoder {
168169}
169170
170171pub ( crate ) struct Decode < ' a > {
171- base : std :: str:: Chars < ' a > ,
172+ base : core :: str:: Chars < ' a > ,
172173 pub ( crate ) insertions : & ' a [ ( usize , char ) ] ,
173174 inserted : usize ,
174175 position : usize ,
Original file line number Diff line number Diff line change 1111
1212use self :: Mapping :: * ;
1313use crate :: punycode;
14- use std:: { error:: Error as StdError , fmt} ;
14+
15+ use alloc:: string:: String ;
16+ use core:: fmt;
1517use unicode_bidi:: { bidi_class, BidiClass } ;
1618use unicode_normalization:: char:: is_combining_mark;
1719use unicode_normalization:: { is_nfc, UnicodeNormalization } ;
@@ -70,10 +72,10 @@ fn find_char(codepoint: char) -> &'static Mapping {
7072}
7173
7274struct Mapper < ' a > {
73- chars : std :: str:: Chars < ' a > ,
75+ chars : core :: str:: Chars < ' a > ,
7476 config : Config ,
7577 errors : & ' a mut Errors ,
76- slice : Option < std :: str:: Chars < ' static > > ,
78+ slice : Option < core :: str:: Chars < ' static > > ,
7779}
7880
7981impl < ' a > Iterator for Mapper < ' a > {
@@ -708,7 +710,8 @@ impl From<Errors> for Result<(), Errors> {
708710 }
709711}
710712
711- impl StdError for Errors { }
713+ #[ cfg( feature = "std" ) ]
714+ impl std:: error:: Error for Errors { }
712715
713716impl fmt:: Display for Errors {
714717 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
You can’t perform that action at this time.
0 commit comments