This Rust program fetches a random cat fact from the Cat Fact Ninja API using the reqwest and serde_json crates. The retrieved JSON response is then parsed, and the cat fact is printed to the console.
- Rust programming language
- Cargo package manager
-
Clone the repository:
git clone https://github.com/VimalanS369/meow-fact.git cd meow-fact
-
Build the project using Cargo:
cargo build --release
-
Run the executable:
./target/release/meow-fact
- Ensure an active internet connection to fetch cat facts from the Cat Fact Ninja API.
- The program fetches a random cat fact from the Cat Fact Ninja API and prints it to the console.
"The first formal cat show was held in England in 1871; in America, in 1895."
- reqwest: A simple HTTP client for Rust.
- serde_json: A JSON serialization/deserialization library for Rust.
The program utilizes Rust's error handling mechanism and returns a Result
with a Box<dyn Error>
trait to handle potential errors during execution.
Feel free to modify and use the code as needed! If you encounter any issues or have suggestions, please open an issue on the GitHub repository. Contributions are welcome!