Crates.io | data_type_checker |
lib.rs | data_type_checker |
version | 0.1.3 |
source | src |
created_at | 2024-10-29 18:01:07.972872 |
updated_at | 2024-11-10 11:38:16.272672 |
description | A lightweight Rust library for validating and converting data types from strings. |
homepage | |
repository | https://github.com/bensatlantik/data_type_checker |
max_upload_size | |
id | 1427429 |
size | 5,750 |
This repository was a gift from me to the Rust and open-source community. It is no longer actively maintained and has been archived. Feel free to fork and continue development on your own.
data_type_checker
is a lightweight Rust library for validating and converting string data into different data types, making it easy to handle dynamic inputs in your applications.
Add type_checker
to your Cargo.toml
:
[dependencies]
data_type_checker = "0.1.0"```
## Usage
```rust
use data_type_checker::TypeChecker;
fn main() {
let num_str = "42";
if TypeChecker::is_int(num_str) {
println!("'{}' is an integer!", num_str);
}
if let Some(value) = TypeChecker::to_int(num_str) {
println!("Parsed integer: {}", value);
}
}
is_int: Checks if a string can be parsed as an integer. is_float: Checks if a string can be parsed as a float. is_bool: Checks if a string represents a boolean. to_int: Attempts to parse a string into an integer, returning None if it fails. to_float: Attempts to parse a string into a float, returning None if it fails. to_bool: Attempts to parse a string into a boolean, returning None if it fails.
This project is licensed under the MIT License
Ben Santora