Skip to content

Commit

Permalink
Address warning when using --no-default-features.
Browse files Browse the repository at this point in the history
  • Loading branch information
01mf02 committed Dec 17, 2024
1 parent 860a674 commit dd9d016
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
8 changes: 5 additions & 3 deletions jaq-core/src/load/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ mod prec_climb;
pub mod test;

use crate::{ops, path};
use alloc::{boxed::Box, string::String, vec::Vec};
#[cfg(feature = "std")]
use alloc::boxed::Box;
use alloc::{string::String, vec::Vec};
pub use lex::Lexer;
use lex::Token;
pub use parse::Parser;
use parse::{BinaryOp, Def, Term};
use parse::{Def, Term};
#[cfg(feature = "std")]
use std::path::{Path, PathBuf};

Expand Down Expand Up @@ -208,7 +210,7 @@ impl<S: PartialEq> Term<S> {

fn unconcat(&self) -> Box<dyn Iterator<Item = &Self> + '_> {
match self {
Self::BinOp(l, BinaryOp::Comma, r) => Box::new(l.unconcat().chain(r.unconcat())),
Self::BinOp(l, parse::BinaryOp::Comma, r) => Box::new(l.unconcat().chain(r.unconcat())),
_ => Box::new(core::iter::once(self)),
}
}
Expand Down
1 change: 1 addition & 0 deletions jaq-core/src/load/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ pub enum BinaryOp {
}

impl<S> Term<S> {
#[cfg(feature = "std")]
pub(crate) fn as_str(&self) -> Option<&S> {
if let Term::Str(None, s) = self {
if let [StrPart::Str(s)] = &s[..] {
Expand Down
11 changes: 8 additions & 3 deletions jaq-json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,19 @@ fn str_windows(line: &str, n: usize) -> impl Iterator<Item = &str> {
/// Functions of the standard library.
#[cfg(feature = "parse")]
pub fn funs() -> impl Iterator<Item = Filter<Native<Val>>> {
let base_run = base_funs().into_vec().into_iter().map(run);
base_run.chain([run(parse_fun())])
base_funs().chain([run(parse_fun())])
}

/// Minimal set of filters for JSON values.
pub fn base_funs() -> impl Iterator<Item = Filter<Native<Val>>> {
base().into_vec().into_iter().map(run)
}

fn box_once_err<'a>(r: ValR) -> BoxIter<'a, ValX<'a>> {
box_once(r.map_err(Exn::from))
}

fn base_funs() -> Box<[Filter<RunPtr<Val>>]> {
fn base() -> Box<[Filter<RunPtr<Val>>]> {
Box::new([
("tojson", v(0), |_, cv| {
box_once(Ok(cv.1.to_string().into()))
Expand Down Expand Up @@ -472,6 +476,7 @@ impl Val {
}
}

#[cfg(feature = "parse")]
/// If the value is a string, return it, else fail.
fn as_str(&self) -> Result<&Rc<String>, Error> {
match self {
Expand Down
2 changes: 2 additions & 0 deletions jaq-std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ trait ValTx: ValT + Sized {
.ok_or_else(|| Error::typ(self.clone(), "integer"))
}

#[cfg(feature = "math")]
/// Use as an i32 to be given as an argument to a libm function.
fn try_as_i32(&self) -> Result<i32, Error<Self>> {
self.try_as_isize()?.try_into().map_err(Error::str)
Expand Down Expand Up @@ -607,6 +608,7 @@ fn error<V, F>() -> Filter<(RunPtr<V, F>, UpdatePtr<V, F>)> {
("error", v(0), (|_, cv| err(cv), |_, cv, _| err(cv)))
}

#[cfg(feature = "log")]
/// Construct a filter that applies an effect function before returning its input.
macro_rules! id_with {
( $eff:expr ) => {
Expand Down

0 comments on commit dd9d016

Please sign in to comment.