Skip to content

Commit c49cc8f

Browse files
committed
Make bytecode no_std compatible
1 parent 39c18fe commit c49cc8f

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

bytecode/Cargo.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ edition = "2018"
77
repository = "https://github.com/RustPython/RustPython"
88
license = "MIT"
99

10+
[features]
11+
std = ["bstr/std", "itertools/use_std", "lz4_flex/std"]
12+
default = ["std"]
1013

1114
[dependencies]
1215
bincode = "1.1"
1316
bitflags = "1.1"
14-
lz4_flex = "0.7"
15-
num-bigint = { version = "0.3", features = ["serde"] }
16-
num-complex = { version = "0.3", features = ["serde"] }
17+
lz4_flex = { version = "0.7", default-features = false, features = ["safe-decode", "safe-encode"] }
18+
num-bigint = { version = "0.3", default-features = false, features = ["serde"] }
19+
num-complex = { version = "0.3", default-features = false, features = ["serde"] }
1720
serde = { version = "1.0", features = ["derive"] }
18-
itertools = "0.9"
19-
bstr = "0.2"
21+
itertools = { version = "0.9", default-features = false }
22+
bstr = { version = "0.2", default-features = false }

bytecode/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33
44
#![doc(html_logo_url = "https://raw.githubusercontent.com/RustPython/RustPython/master/logo.png")]
55
#![doc(html_root_url = "https://docs.rs/rustpython-bytecode/")]
6+
#![cfg_attr(not(feature = "std"), no_std)]
67

8+
extern crate alloc;
9+
10+
use alloc::collections::BTreeSet;
11+
use alloc::{borrow::ToOwned, boxed::Box, string::String, vec::Vec};
712
use bitflags::bitflags;
813
use bstr::ByteSlice;
14+
use core::fmt;
915
use itertools::Itertools;
1016
use num_bigint::BigInt;
1117
use num_complex::Complex64;
1218
use serde::{Deserialize, Serialize};
13-
use std::collections::BTreeSet;
14-
use std::fmt;
1519

1620
/// Sourcecode location.
1721
#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize)]
@@ -722,6 +726,7 @@ impl fmt::Display for CodeDeserializeError {
722726
}
723727
}
724728
}
729+
#[cfg(feature = "std")]
725730
impl std::error::Error for CodeDeserializeError {}
726731

727732
impl CodeObject<ConstantData> {

0 commit comments

Comments
 (0)