2023-03-22
2084
#rust
Yashodhan Joshi
163607
109
Mar 22, 2023 â‹… 7 min read

Using Cow in Rust for efficient memory utilization

Yashodhan Joshi I am a student interested in physics and systems programming currently exploring Rust and operating systems. I am also passionate about helping others learn.

Recent posts:

Decoupling Monoliths Into Microservices With Feature Flags

Decoupling monoliths into microservices with feature flags

Explore how to effectively break down a monolithic application into microservices using feature flags and Flagsmith.

Kayode Adeniyi
Jul 25, 2024 â‹… 10 min read
Lots of multi-colored blue and purplish rectangles.

Animating dialog and popover elements with CSS @starting-style

Native dialog and popover elements have their own well-defined roles in modern-day frontend web development. Dialog elements are known to […]

Rahul Chhodde
Jul 24, 2024 â‹… 10 min read
Using Llama Index To Add Personal Data To Large Language Models

Using LlamaIndex to add personal data to LLMs

LlamaIndex provides tools for ingesting, processing, and implementing complex query workflows that combine data access with LLM prompting.

Ukeje Goodness
Jul 23, 2024 â‹… 5 min read
JavaScript logo on top of violet background

Exploring essential DOM methods for frontend development

Learn four groups of DOM methods and their uses to create responsive and dynamic webpages. A helpful DOM reference table is also included.

Chimezie Innocent
Jul 23, 2024 â‹… 12 min read
View all posts

3 Replies to "Using Cow in Rust for efficient memory utilization"

  1. I really enjoyed your post. It really helped understand the problem well.
    I think there is a small bug, it doesn’t distract much from the value of the post, but it’s always nice if the code works. The first example is missing `seen_ids.insert(element.id.clone());`, or something of the sort when looping through the list to track if an id has been seen. The second code snippet has the HashSet insert.

    1. Hey Marc, thanks a lot for noticing and reporting this! The first example was initially supposed to be just a pseudo-code / algorithm, and then the proper code was supposed to be the second snippet. However, While writing and re-writing, I slipped in some code in the first, and the final version had the missing code line that you noticed. In any case I should have taken more care.
      Thanks a lot for commenting this, I have fixed the error now. Hope you found this post useful and fun to read!

  2. Consider a search and replace program that searches for a particular text and if found, replaces it with another text in a UTF-8 encoded text file. Most of the time, the text file contains none or only a few occurrences of the search text. As the program parses each line in the text file, only if the search text is found, that line should be mutated. Otherwise no need to mutate that line. Cow is perfectly suitable for this use case.

Leave a Reply