Skip to main content

Awk

Struct Awk 

Source
pub struct Awk { /* private fields */ }
Expand description

High-level wrapper for compiling and running an AWK script.

This type parses the script once and can be run with different input.

§Example

use rawk_core::awk::Awk;

let awk = Awk::new("{ print }");
let output = awk.run(vec!["hello world".into()], None);
assert_eq!(output, vec!["hello world".to_string()]);

Implementations§

Source§

impl Awk

Source

pub fn new(script: impl Into<String>) -> Self

Parse an AWK script into an executable program.

The script is stored with a static lifetime to keep the AST valid.

Source

pub fn run(&self, input: Vec<String>, filename: Option<String>) -> Vec<String>

Execute the compiled program against the given input lines.

When filename is None, FILENAME defaults to "-".

Auto Trait Implementations§

§

impl Freeze for Awk

§

impl RefUnwindSafe for Awk

§

impl Send for Awk

§

impl Sync for Awk

§

impl Unpin for Awk

§

impl UnsafeUnpin for Awk

§

impl UnwindSafe for Awk

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.