N00b question: What is the difference between a cons list and a linked list?

Hello there!

I'm new to Rust, coming from C. While reading the Rust Book I didn't quite get if there is a significant difference between cons and linked lists, or if it is simply a difference in names.

Sorry if this might be an obvious question, but I'm just bamboozled...

1 Like

The "cons" thing is a specific kind of linked list, namely a singly linked list, on which it is typically possible to share the tail of the list between multiple lists.

3 Likes

Thank you for this immediate answer. Solves my question adequately :slight_smile:

As a extension of @alice answer:
The general concept is called "immutable data structures" and is mostly used in functional programming languages but also can be used in imperative ones (its just not so common).

There is some good material on the internet, the name of the concept should be enough to find basically unlimited material on the topic.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.