Skip to content

Commit 6d622ab

Browse files
committed
Moved to no-std-net
1 parent 315eb43 commit 6d622ab

File tree

8 files changed

+19
-22
lines changed

8 files changed

+19
-22
lines changed

.github/workflows/main.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
with:
3535
toolchain: ${{ matrix.rust }}
3636
# Add toolchain for no_std tests
37+
- run: rustup toolchain install nightly
3738
- run: rustup target add aarch64-unknown-none
3839
- run: cargo build --all-targets
3940
# Run tests
@@ -50,7 +51,7 @@ jobs:
5051
matrix.rust == 'nightly'
5152
run: cargo test --test debugger_visualizer --features "url/serde,url/debugger_visualizer" -- --test-threads=1
5253
- name: Test `no_std` support
53-
run: cargo +nightly test --no-default-features --features=alloc
54+
run: cargo test --no-default-features --features=alloc
5455
- name: Build `aarch64-unknown-none` with `no_std`
5556
run: cargo +nightly build -Zbuild-std=core,alloc --target aarch64-unknown-none -v --release --no-default-features --features=alloc
5657

data-url/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ alloc = []
1717

1818
[dev-dependencies]
1919
tester = "0.9"
20-
serde = {version = "1.0", features = ["derive"]}
20+
serde = { version = "1.0", default-features = false, features = ["alloc", "derive"] }
2121
serde_json = "1.0"
2222

2323
[lib]

idna/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ name = "unit"
2929
assert_matches = "1.3"
3030
bencher = "0.1"
3131
tester = "0.9"
32-
serde_json = "1.0"
32+
serde_json = { version = "1.0" }
3333

3434
[dependencies]
3535
unicode-bidi = { version = "0.3.10", default-features = false, features = ["hardcoded-data"] }

idna/tests/punycode.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
use crate::test::TestFn;
1010
use idna::punycode::{decode, encode_str};
11-
use serde_json::map::Map;
12-
use serde_json::Value;
11+
use serde_json::{map::Map, Value};
1312
use std::str::FromStr;
1413

1514
fn one_test(decoded: &str, encoded: &str) {

url/Cargo.toml

+9-6
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,23 @@ debugger_test = "0.1"
2828
debugger_test_parser = "0.1"
2929

3030
[dependencies]
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 }
34-
serde = {version = "1.0", optional = true, features = ["derive"]}
31+
form_urlencoded = { version = "1.1.0", path = "../form_urlencoded", default-features = false, features = ["alloc"] }
32+
idna = { version = "0.3.0", path = "../idna", default-features = false, features = ["alloc"] }
33+
percent-encoding = { version = "2.2.0", path = "../percent_encoding", default-features = false, features = ["alloc"] }
34+
data-url = { version = "0.2.0", path = "../data-url", default-features = false, features = ["alloc"] }
35+
serde = {version = "1.0", optional = true, default-features = false, features = ["alloc", "derive"]}
36+
no-std-net = { version = "0.6.0", default-features = false }
3537

3638
[features]
3739
default = ["std"]
38-
std = ["idna/std", "percent-encoding/std", "form_urlencoded/std", "alloc"]
39-
alloc = ["idna/alloc", "percent-encoding/alloc", "form_urlencoded/alloc"]
40+
std = ["idna/std", "percent-encoding/std", "form_urlencoded/std", "no-std-net/std", "alloc"]
41+
alloc = []
4042
# UNSTABLE FEATURES (requires Rust nightly)
4143
# Enable to use the #[debugger_visualizer] attribute.
4244
debugger_visualizer = []
4345
# Expose internal offsets of the URL.
4446
expose_internals = []
47+
serde = ["dep:serde", "no-std-net/serde"]
4548

4649
[[bench]]
4750
name = "parse_url"

url/src/host.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,11 @@ use alloc::{
1111
string::{String, ToString},
1212
vec::Vec,
1313
};
14-
#[cfg(not(feature = "std"))]
15-
use core::net::{Ipv4Addr, Ipv6Addr};
1614
use core::{
1715
cmp,
1816
fmt::{self, Formatter},
1917
};
20-
#[cfg(feature = "std")]
21-
use std::net::{Ipv4Addr, Ipv6Addr};
18+
use no_std_net::{Ipv4Addr, Ipv6Addr};
2219

2320
use percent_encoding::{percent_decode, utf8_percent_encode, CONTROLS};
2421
#[cfg(feature = "serde")]

url/src/lib.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ url = { version = "2", features = ["serde"] }
128128
debugger_visualizer(natvis_file = "../../debug_metadata/url.natvis")
129129
)]
130130
#![no_std]
131-
#![cfg_attr(not(feature = "std"), feature(ip_in_core))]
132131

133132
pub use form_urlencoded;
134133

@@ -155,13 +154,11 @@ use core::convert::TryFrom;
155154
use core::fmt::{self, Write};
156155
use core::hash;
157156
use core::mem;
158-
#[cfg(not(feature = "std"))]
159-
use core::net::IpAddr;
160157
use core::ops::{Range, RangeFrom, RangeTo};
161158
use core::str;
159+
use no_std_net::IpAddr;
162160
use percent_encoding::utf8_percent_encode;
163-
#[cfg(feature = "std")]
164-
use std::net::IpAddr;
161+
165162
#[cfg(feature = "std")]
166163
use std::{
167164
io,

url/tests/unit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
//! Unit tests
1010
11+
use core::cell::{Cell, RefCell};
12+
use no_std_net::{Ipv4Addr, Ipv6Addr};
1113
use std::borrow::Cow;
12-
use std::cell::{Cell, RefCell};
13-
use std::net::{Ipv4Addr, Ipv6Addr};
1414
#[cfg(feature = "std")]
1515
use std::path::{Path, PathBuf};
1616
use url::{form_urlencoded, Host, Origin, Url};

0 commit comments

Comments
 (0)