Skip to content
This repository was archived by the owner on Jul 27, 2023. It is now read-only.

Commit d7d4ad4

Browse files
charliermarshzanieb
authored andcommitted
Make malachite-bigint an optional dependency for rustpython-format (#12)
1 parent a4388aa commit d7d4ad4

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

format/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ rustpython-literal = { workspace = true }
1212

1313
bitflags = "2.3.1"
1414
itertools = "0.10.5"
15-
malachite-bigint = { workspace = true }
1615
num-traits = { workspace = true }
16+
num-bigint = { workspace = true, optional = true }
17+
malachite-bigint = { workspace = true, optional = true }

format/src/cformat.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//! Implementation of Printf-Style string formatting
22
//! as per the [Python Docs](https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting).
33
use bitflags::bitflags;
4-
use malachite_bigint::{BigInt, Sign};
54
use num_traits::Signed;
65
use rustpython_literal::{float, format::Case};
76
use std::{
@@ -10,6 +9,8 @@ use std::{
109
str::FromStr,
1110
};
1211

12+
use crate::bigint::{BigInt, Sign};
13+
1314
#[derive(Debug, PartialEq)]
1415
pub enum CFormatErrorType {
1516
UnmatchedKeyParentheses,

format/src/format.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
use itertools::{Itertools, PeekingNext};
2-
use malachite_bigint::{BigInt, Sign};
3-
use num_traits::FromPrimitive;
4-
use num_traits::{cast::ToPrimitive, Signed};
2+
3+
use num_traits::{cast::ToPrimitive, FromPrimitive, Signed};
54
use rustpython_literal::float;
65
use rustpython_literal::format::Case;
76
use std::ops::Deref;
87
use std::{cmp, str::FromStr};
98

9+
use crate::bigint::{BigInt, Sign};
10+
1011
trait FormatParse {
1112
fn parse(text: &str) -> (Option<Self>, &str)
1213
where

format/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
pub mod cformat;
2-
mod format;
1+
#[cfg(feature = "malachite-bigint")]
2+
pub use malachite_bigint as bigint;
3+
#[cfg(feature = "num-bigint")]
4+
pub use num_bigint as bigint;
35

46
pub use crate::format::*;
7+
8+
pub mod cformat;
9+
mod format;

0 commit comments

Comments
 (0)