Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON data faker #96

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix no_std build
anweiss committed Oct 11, 2021

Verified

This commit was signed with the committer’s verified signature. The key has expired.
anweiss anweiss
commit 7aa0015bc7f63140f0deb2fb9d145aecfbbc6b9b
7 changes: 7 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
use crate::{ast::*, token::*};

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

#[cfg(feature = "std")]
use regex_syntax;

/// Find non-choice alternate rule from a given identifier
pub fn rule_from_ident<'a>(cddl: &'a CDDL, ident: &Identifier) -> Option<&'a Rule<'a>> {
cddl.rules.iter().find_map(|r| match r {
@@ -604,6 +610,7 @@ pub struct EntryCount {

/// Regex needs to be formatted in a certain way so it can be parsed. See
/// <https://github.com/anweiss/cddl/issues/67>
#[cfg(feature = "std")]
pub fn format_regex(input: &str) -> Option<String> {
let mut formatted_regex = String::from(input);
let mut unescape = Vec::new();