pub struct CountRoo {
pub config: Config,
pub total_lines: usize,
pub num_files: usize,
pub num_crates: usize,
pub project_name: Option<String>,
pub rust_edition: Option<String>,
pub rustc_version: Option<String>,
pub num_modules: usize,
}
Expand description
CountRoo
๐ฆ - Your Rust Projectโs Best Mate for Code Insights!
Embark on an adventure through your codebase with CountRoo
, the struct that leaps across
your files, counting lines of code, tracking crates, and more, all while keeping it fun! ๐
ยงFeatures
- Total Lines of Code ๐: Keeps track of the total lines across your project.
- Number of Files ๐๏ธ: Counts the files explored in the code safari.
- Crate Count ๐ฆ: Tallies up the crates your project depends on.
- Project Name ๐ท๏ธ: Captures the name of your project, if available.
- Rust Edition ๐ฆ: Identifies the Rust edition your project is using.
- Rust Compiler Version ๐ง: Determines the version of the Rust compiler (
rustc
) in use. - Module Count ๐: Counts the number of modules within your Rust project.
ยงExample
use countroo::prelude::*;
let config = Config::from_rel_file_path("path/to/config").unwrap();
let mut countroo = CountRoo::default();
let total_lines = countroo.count_lines_of_code().unwrap();
println!("Total lines of code: {}", total_lines);///
// Or you could just use macros for convenience such as count_some!() or count_it_all!()
Dive in and let CountRoo
uncover the hidden gems and forgotten fossils in your codebase. Happy counting! ๐
Fieldsยง
ยงconfig: Config
ยงtotal_lines: usize
ยงnum_files: usize
ยงnum_crates: usize
ยงproject_name: Option<String>
ยงrust_edition: Option<String>
ยงrustc_version: Option<String>
ยงnum_modules: usize
Implementationsยง
sourceยงimpl CountRoo
impl CountRoo
pub fn count_lines_of_code(&mut self) -> Result<usize, LocCounterError>
pub fn count_lines_for_file( count_empty_lines: bool, entry: &String ) -> Result<usize, LocCounterError>
sourcepub fn calculate_extension_counts(&self) -> HashMap<String, usize>
pub fn calculate_extension_counts(&self) -> HashMap<String, usize>
Calculates and aggregates the lines of code per occurrences of each file extension within the projectโs source directory.
ยงArguments
self
: A reference to the current instance of the struct.
ยงReturns
A HashMap where:
- Keys are strings representing unique file extensions found.
- Values are the corresponding counts of files with that extension.
ยงAssumptions
- The
config
member of the struct holds relevant configuration data. config.count_empty_lines
influences the counting behavior (Toggling it to true marks whitespace new lines as code lines).config.project_src_path
defines the base directory for searching files (Usually src folder).
pub fn calculate_extension_counts_for( count_empty_lines: bool, path: &String ) -> HashMap<String, usize>
pub fn with_config_builder( config_builder: ConfigBuilder ) -> Result<Self, LocCounterError>
Trait Implementationsยง
sourceยงimpl AllTypesCounter for CountRoo
impl AllTypesCounter for CountRoo
fn count_lines_of_code_for_all_types( &mut self ) -> Result<usize, LocCounterError>
sourceยงimpl Analyzable for CountRoo
impl Analyzable for CountRoo
fn get_project_base(&self) -> String
fn is_code_file(&self, path: &str) -> bool
fn get_manifest(&self) -> Result<Manifest, LocCounterError>
fn count_code_files(&self, project_path: &str) -> Result<usize, LocCounterError>
fn count_crates(&self) -> Result<usize, LocCounterError>
fn get_project_name(&self) -> Result<Option<String>, LocCounterError>
fn get_rust_version() -> Option<String>
fn get_rust_edition(&self) -> Option<String>
fn count_rust_modules(project_path: &str) -> Result<usize, LocCounterError>
fn analyze_code_base(&mut self)
sourceยงimpl CertainTypesCounter for CountRoo
impl CertainTypesCounter for CountRoo
fn count_lines_of_code_for_certain_types( &mut self ) -> Result<usize, LocCounterError>
Auto Trait Implementationsยง
impl RefUnwindSafe for CountRoo
impl Send for CountRoo
impl Sync for CountRoo
impl Unpin for CountRoo
impl UnwindSafe for CountRoo
Blanket Implementationsยง
sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
ยงimpl<T> Instrument for T
impl<T> Instrument for T
ยงfn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
ยงfn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
ยงimpl<T> Pointable for T
impl<T> Pointable for T
ยงimpl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
ยงfn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a [
CompactString
]. Read more