Skip to content
This repository has been archived by the owner on Nov 30, 2024. It is now read-only.

Commit

Permalink
add utility methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoskal committed Sep 7, 2024
1 parent f437079 commit 8828701
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ impl StepArg {
sampled,
}
}

pub fn from_sampled_token(tok: TokenId) -> Self {
StepArg {
backtrack: 0,
tokens: vec![tok],
sampled: Some(tok),
}
}
}

/*
Expand Down Expand Up @@ -105,6 +113,24 @@ pub struct Splice {
pub ff_tokens: Vec<TokenId>,
}

impl Splice {
pub fn noop() -> Self {
Splice {
when_sampled: vec![],
backtrack: 0,
ff_tokens: vec![],
}
}

pub fn tokens(ff_tokens: Vec<TokenId>) -> Self {
Splice {
when_sampled: vec![],
backtrack: 0,
ff_tokens,
}
}
}

#[derive(Serialize, Deserialize, Debug)]
pub struct Branch<S> {
/// If None, no sampling is performed.
Expand Down

0 comments on commit 8828701

Please sign in to comment.