Skip to content

A simple lineparsing utility as a counterpart to println!

License

Notifications You must be signed in to change notification settings

albheim/parseline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

parseln! - a println! counterpart

Test with Code Coverage Check and Lint Codecov

A small helper crate to parse strings using a similar syntax as used in the println! macro.

Installation

To use this library in a project simply add

[dependencies]
parseline = { git = "https://github.com/albheim/parseline" }

to your project Cargo.toml and then import parseline as

use parseline::parseln;

Usage

It can be used either with already defined variables as

let month: String;
let day: isize;
parseln!("Date: apr 13", "Date: {} {}", month, day);

or by generating new binding, though then we need to supply the type to be parsed

parseln!("Date: apr 13", "Date: {} {}", month: String, day: i32);

TODO

  • Currently it is not possible to mix these methods.
  • Allow for writing to references, automatically dereference?
  • cargo doc?
  • Don't do split->collect->iter, check macro book for tips on how to do indexing in repeating macros.

Disclaimer

This is the first crate I have made and it was mostly as a learning experience. I needed some parsing for Advent of Code and thought regular expressions were overkill, and figuring out how to set up a crate with tests and how to create the needed macro was a good learning experience.

About

A simple lineparsing utility as a counterpart to println!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages