split

Function split 

Source
pub fn split(
    filename: &str,
    code: &str,
    options: &SplitOptions,
) -> Result<Vec<Chunk>>
Expand description

Splits the given code into chunks based on the provided options.

§Arguments

  • filename - The name of the file containing the code.
  • code - The source code to be split.
  • options - The options for splitting the code.

§Returns

A Result containing a vector of Chunks if successful, or an error if parsing fails.

§Example

use devgen_splitter::{
    split,
    SplitOptions,
};

let code = "fn main() { println!(\"Hello, world!\"); }";
let options = SplitOptions {
    chunk_line_limit: 5,
};
let chunks = split("example.rs", code, &options).unwrap();