Crates.io | vector_converter |
lib.rs | vector_converter |
version | 0.1.1 |
source | src |
created_at | 2024-11-05 21:14:11.961959 |
updated_at | 2024-11-05 22:58:18.774852 |
description | A library to convert between vectors of different types. |
homepage | https://github.com/bensatlantik/vector_converter |
repository | https://github.com/bensatlantik/vector_converter |
max_upload_size | |
id | 1437167 |
size | 4,253 |
A simple Rust library to convert between vectors of different types, such as converting a vector of integers to a vector of strings and vice versa.
To use the vector_converter
library in your Rust project, add the following to your Cargo.toml
:
[dependencies]
vector_converter = "0.1"
Convert Integer Vector to String Vector
use vector_converter::int_vec_to_string_vec;
fn main() {
let int_vec = vec![1, 2, 3];
let string_vec = int_vec_to_string_vec(int_vec);
println!("{:?}", string_vec); // Output: ["1", "2", "3"]
}
Convert String Vector to Integer Vector
use vector_converter::string_vec_to_int_vec;
fn main() {
let string_vec = vec!["1".to_string(), "2".to_string(), "3".to_string()];
match string_vec_to_int_vec(string_vec) {
Ok(int_vec) => println!("{:?}", int_vec), // Output: [1, 2, 3]
Err(e) => println!("Error: {}", e),
}
}
This project is licensed under the MIT License
Ben Santora bensatlantik@gmail.com