This repository has been archived on 2024-10-16. You can view files and clone it, but cannot push or open issues or pull requests.
pt/members/libpt-core/src/lib.rs

24 lines
851 B
Rust
Raw Normal View History

//! # common functionalities
//!
2023-09-20 20:35:07 +02:00
//! This crate is part of [`pt`](../libpt/index.html), but can also be used as a standalone
//! module.
//!
//! This crate implements core functionality useful for many use cases, such as macros,
//! formatting functions and more.
2023-07-09 17:53:20 +02:00
/// macros to make things faster in your code
pub mod macros;
/// ## Get the name of the crate that uses your library
///
/// Let's say you're writing the library `foo` and need the name of the crate that uses `foo`. With
/// this function, you can get the name of the crate that uses `foo`.
///
/// Will return [None] if [`std::env::current_exe()`] errors or if conversion to [String] from [std::ffi::OsStr] fails.
pub fn get_crate_name() -> Option<String> {
if let Ok(exe) = std::env::current_exe() {
return Some(exe.file_stem()?.to_str()?.to_string());
}
None
}