Skip to content

Commit a98aef8

Browse files
committed
fix no_std for nightly
1 parent bb7955a commit a98aef8

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

idna/src/uts46.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ impl Idna {
453453
return Errors::default();
454454
}
455455
let mut errors = processing(domain, self.config, &mut self.normalized, out);
456-
self.output = std::mem::replace(out, String::with_capacity(out.len()));
456+
self.output = core::mem::replace(out, String::with_capacity(out.len()));
457457
let mut first = true;
458458
for label in self.output.split('.') {
459459
if !first {

url/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ debugger_test = "0.1"
2828
debugger_test_parser = "0.1"
2929

3030
[dependencies]
31-
form_urlencoded = { version = "1.1.0", path = "../form_urlencoded" }
32-
idna = { version = "0.3.0", path = "../idna" }
33-
percent-encoding = { version = "2.2.0", path = "../percent_encoding" }
31+
form_urlencoded = { version = "1.1.0", path = "../form_urlencoded", default-features = false }
32+
idna = { version = "0.3.0", path = "../idna", default-features = false }
33+
percent-encoding = { version = "2.2.0", path = "../percent_encoding", default-features = false }
3434
serde = {version = "1.0", optional = true, features = ["derive"]}
3535

3636
[features]
3737
default = ["std"]
38-
std = ["idna/std", "alloc"]
38+
std = ["idna/std", "percent-encoding/std", "form_urlencoded/std", "alloc"]
3939
alloc = []
4040
# UNSTABLE FEATURES (requires Rust nightly)
4141
# Enable to use the #[debugger_visualizer] attribute.

url/src/host.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ use alloc::{
1111
string::{String, ToString},
1212
vec::Vec,
1313
};
14+
#[cfg(not(feature = "std"))]
15+
use core::net::{Ipv4Addr, Ipv6Addr};
1416
use core::{
1517
cmp,
1618
fmt::{self, Formatter},
1719
};
20+
#[cfg(feature = "std")]
1821
use std::net::{Ipv4Addr, Ipv6Addr};
1922

2023
use percent_encoding::{percent_decode, utf8_percent_encode, CONTROLS};

url/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,16 @@ url = { version = "2", features = ["serde"] }
127127
feature(debugger_visualizer),
128128
debugger_visualizer(natvis_file = "../../debug_metadata/url.natvis")
129129
)]
130+
#![no_std]
131+
#![cfg_attr(not(feature = "std"), feature(ip_in_core))]
130132

131133
pub use form_urlencoded;
132134

133135
// For forwards compatibility
134136
#[cfg(feature = "std")]
135137
extern crate std;
136138

139+
#[macro_use]
137140
extern crate alloc;
138141

139142
#[cfg(not(feature = "alloc"))]
@@ -152,9 +155,12 @@ use core::convert::TryFrom;
152155
use core::fmt::{self, Write};
153156
use core::hash;
154157
use core::mem;
158+
#[cfg(not(feature = "std"))]
159+
use core::net::IpAddr;
155160
use core::ops::{Range, RangeFrom, RangeTo};
156161
use core::str;
157162
use percent_encoding::utf8_percent_encode;
163+
#[cfg(feature = "std")]
158164
use std::net::IpAddr;
159165
#[cfg(feature = "std")]
160166
use std::{

0 commit comments

Comments
 (0)