Ankit Kumar Jha
banner
ankitkumarjha.bsky.social
Ankit Kumar Jha
@ankitkumarjha.bsky.social
Rust Developer 🦀 | Kubernetes | WASM | Haskell | Open Source | Linux 🐧| Like to share/write articles and books 📚
To Learn, Unlearn, Relearn, and then to Change yourself is a superpower where you fight with your current perceptions to adapt new one that's really crazy.💀
March 12, 2025 at 4:13 AM
💥 KodeKloud is officially unlocked!
Great course for starting rust 🦀 programming.

For the next 7 days, you have unlimited access to expert-led courses, real-world labs, and structured learning paths.

Your Access Ends: February 17th :
Make the most of it!
#KodeKloud #rust
February 12, 2025 at 2:23 PM
Today, first time I heard about gelato &
while searching I knew Gelato and Ice cream differ primarily in ingredients, texture, and serving style.
February 7, 2025 at 4:06 PM
Until now, I don't even realise about the AQI(Air Quality Index) in our country. It's really concerning for our life.
One of the basic need of human is Air.

People's need to be educated enough to present questions with authorities and make them accountable.
#Air
February 6, 2025 at 2:42 PM
reading
January 30, 2025 at 4:45 PM
everyone is fighting a battle you know nothing about.
January 18, 2025 at 8:53 AM
Output 🦀
different ways to print output on the screen in rust

👉Use format!() when you need to create a formatted string for later use.

👉Use print!() or println!() for regular console output.

👉Use eprint!() or eprintln!() for error messages or debugging output.
January 16, 2025 at 11:32 AM
Reading from a file:
January 16, 2025 at 11:32 AM
File I/O 🦀
Rust also supports reading from and writing to files using the std::fs module.

Writing to a file:
January 16, 2025 at 11:32 AM
Buffered I/O 🦀
👉For advanced I/O operations, Rust provides buffered readers and writers in the std::io module.

stdin.lock() - Creates a buffered reader for efficient input handling.
January 16, 2025 at 11:32 AM
Handle Errors 🦀
👉Handle parse input Errors with match or if let
January 16, 2025 at 11:32 AM
Parsing Input 🦀
👉If you want to convert user input into a specific type then use parse method.
January 16, 2025 at 11:32 AM
User Input 🦀
👉std::io module provides to read user input.
The std::io::stdin() function provides access to std input
January 16, 2025 at 11:32 AM
If you have right knowledge then it will improve and impact your life.

It’s okay if you’re making money.
If money is being taken away , it’s either temporary or false knowledge.
January 12, 2025 at 1:02 PM
Output:
January 6, 2025 at 11:42 PM
To use the serde and serde_json crates for serialization and deserialization in your Rust project, you need to add the following dependencies to your Cargo.toml file:
January 6, 2025 at 11:42 PM
In the main function, a json string is defined. This JSON string represents an article with the following fields:

article, author, paragraph: A list of paragraphs, each with a title.

The r# syntax allows for a raw string literal.
January 6, 2025 at 11:42 PM
Let’s define struct named Article. This struct contains 3 fields:
1. article
2. author
3. paragraph of type Vec<Paragraph>,
which is a vector containing multiple Paragraph structs. same as above, Article also derives the Serialize and Deserialize traits.
January 6, 2025 at 11:42 PM
Rust struct:

Let’s define a Rust struct named Paragraph.
This struct contains a single field: title, of type String.

The #[derive(Serialize, Deserialize)] attribute ensures that the Paragraph struct can be easily converted to and from JSON format.
January 6, 2025 at 11:42 PM
To handle JSON in Rust, we need to import the essential traits from the serde crate:

Serialize: Converts Rust structures into JSON data.
Deserialize: Parses JSON data into Rust structures.
January 6, 2025 at 11:42 PM

output:
January 5, 2025 at 9:53 PM
To use the serde and serde_json crates for serialization and deserialization in your Rust project,
you need to add the following dependencies to your Cargo.toml file:
January 5, 2025 at 9:53 PM
In main function, we create an instance of the Article struct, with example data.
This struct represents an article with:

a title ('title'),
an author ('author'), and
a list of paragraphs ('paragraph').
January 5, 2025 at 9:53 PM
Rust struct:

Let’s define rust struct named Article. This struct contains 3 fields:

1. article
2. author
3. paragraph of type Vec<Paragraph>, which is a vector containing multiple Paragraph structs.

same as above, Article also derives the Serialize and Deserialize traits.
January 5, 2025 at 9:53 PM
Let’s define a Rust struct named Paragraph.

This struct contains a single field: name, of type String.

The #[derive(Serialize, Deserialize)] attribute ensures that the Paragraph struct can be easily converted to and from JSON format.
January 5, 2025 at 9:53 PM