The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Get A Single Line Of Text With The nom Parser in Rust

TODO: Pull subtitle into page object

This example is a test run, it's not currnetly working as I figure out some details of the neopolitan code runner

Code
#!/usr/bin/env cargo +nightly -Zscript

//! ```cargo
//! [package]
//! edition = "2021"
//! [dependencies]
//! nom = { version = "7.1.3" }
//! ```

use nom::IResult;

fn main() {
  assert_eq!("alfa bravo\ncharlie\n", Ok(("charlie", "alfa bravo"));
  println!("Tests Passed");
}

fn parser(source: &str) -> IResult<&str, &str> {
  Ok((source, ""))
}


//let (a, b) = alt((
 // tuple((take_until("\n"), tag("\n"))).map(|x| x.0),
  //rest,
//))(source)?;
Results
error: mismatched closing delimiter: `}`
  --> tmp-neo-execute-script.rs:13:13
   |
12 | fn main() {
   |           - closing delimiter possibly meant for this
13 |   assert_eq!("alfa bravo\ncharlie\n", Ok(("charlie", "alfa bravo"));
   |             ^ unclosed delimiter
14 |   println!("Tests Passed");
15 | }
   | ^ mismatched closing delimiter

error: could not compile `tmp-neo-execute-script` (bin "tmp-neo-execute-script") due to previous error

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Get A Single Line Of Text With The nom Parser in Rust

-- note

This example is a test run, it's not currnetly 
working as I figure out some details of 
the neopolitan code runner

-- code
-- rust

#!/usr/bin/env cargo +nightly -Zscript

//! ```cargo
//! [package]
//! edition = "2021"
//! [dependencies]
//! nom = { version = "7.1.3" }
//! ```

use nom::IResult;

fn main() {
  assert_eq!("alfa bravo\ncharlie\n", Ok(("charlie", "alfa bravo"));
  println!("Tests Passed");
}

fn parser(source: &str) -> IResult<&str, &str> {
  Ok((source, ""))
}


//let (a, b) = alt((
 // tuple((take_until("\n"), tag("\n"))).map(|x| x.0),
  //rest,
//))(source)?;


-- results/

error: mismatched closing delimiter: `}`
  --> tmp-neo-execute-script.rs:13:13
   |
12 | fn main() {
   |           - closing delimiter possibly meant for this
13 |   assert_eq!("alfa bravo\ncharlie\n", Ok(("charlie", "alfa bravo"));
   |             ^ unclosed delimiter
14 |   println!("Tests Passed");
15 | }
   | ^ mismatched closing delimiter

error: could not compile `tmp-neo-execute-script` (bin "tmp-neo-execute-script") due to previous error

-- /results

12 | fn main() {
   |           - closing delimiter possibly meant for this
13 |   assert_eq!("alfa bravo\ncharlie\n", Ok(("charlie", "alfa bravo"));
   |             ^ unclosed delimiter
14 |   println!("Tests Passed");
15 | }
   | ^ mismatched closing delimiter

error: could not compile `tmp-neo-execute-script` (bin "tmp-neo-execute-script") due to previous error

-- /results

-- categories
-- Rust
-- nom

-- metadata
-- date: 2023-04-15 17:02:42
-- id: 2otlgobu
-- site: aws
-- type: scratch 
-- status: published