From d4ec4e08738f5ee855dddc8e8e3b8758d1c10020 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 19 Jun 2023 16:25:00 -0400 Subject: [PATCH] Make malachite-bigint an optional dependency for rustpython-format --- format/Cargo.toml | 3 ++- format/src/cformat.rs | 3 ++- format/src/format.rs | 7 ++++--- format/src/lib.rs | 9 +++++++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/format/Cargo.toml b/format/Cargo.toml index 7a9db255..a9185b5a 100644 --- a/format/Cargo.toml +++ b/format/Cargo.toml @@ -12,5 +12,6 @@ rustpython-literal = { workspace = true } bitflags = "2.3.1" itertools = "0.10.5" -malachite-bigint = { workspace = true } num-traits = { workspace = true } +num-bigint = { workspace = true, optional = true } +malachite-bigint = { workspace = true, optional = true } diff --git a/format/src/cformat.rs b/format/src/cformat.rs index a207857e..d835fda0 100644 --- a/format/src/cformat.rs +++ b/format/src/cformat.rs @@ -1,7 +1,6 @@ //! Implementation of Printf-Style string formatting //! as per the [Python Docs](https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting). use bitflags::bitflags; -use malachite_bigint::{BigInt, Sign}; use num_traits::Signed; use rustpython_literal::{float, format::Case}; use std::{ @@ -10,6 +9,8 @@ use std::{ str::FromStr, }; +use crate::bigint::{BigInt, Sign}; + #[derive(Debug, PartialEq)] pub enum CFormatErrorType { UnmatchedKeyParentheses, diff --git a/format/src/format.rs b/format/src/format.rs index 09cc3d1a..6bc5796e 100644 --- a/format/src/format.rs +++ b/format/src/format.rs @@ -1,12 +1,13 @@ use itertools::{Itertools, PeekingNext}; -use malachite_bigint::{BigInt, Sign}; -use num_traits::FromPrimitive; -use num_traits::{cast::ToPrimitive, Signed}; + +use num_traits::{cast::ToPrimitive, FromPrimitive, Signed}; use rustpython_literal::float; use rustpython_literal::format::Case; use std::ops::Deref; use std::{cmp, str::FromStr}; +use crate::bigint::{BigInt, Sign}; + trait FormatParse { fn parse(text: &str) -> (Option, &str) where diff --git a/format/src/lib.rs b/format/src/lib.rs index 3c5d8695..d3833c18 100644 --- a/format/src/lib.rs +++ b/format/src/lib.rs @@ -1,4 +1,9 @@ -pub mod cformat; -mod format; +#[cfg(feature = "malachite-bigint")] +pub use malachite_bigint as bigint; +#[cfg(feature = "num-bigint")] +pub use num_bigint as bigint; pub use crate::format::*; + +pub mod cformat; +mod format;