Of course, if this is a solved problem, a chapter in a book, or post on
Stack Overflow should be sufficient, but I thought to ask here first.
Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote or quoted:
Of course, if this is a solved problem, a chapter in a book, or post on
Stack Overflow should be sufficient, but I thought to ask here first.
Since Rust already has std::collections::LinkedList, doubly-linked
lists with owned nodes, there's little need to implement something
like this, unless as an exercise.
If one wants to use lists, one should also check if std::collections
::VecDeque can be used. It has O(1) push/pop at the front and back
and is cache-friendly.
the book talks about shadowing variables, with a completely new type.
The Rustafarians think that
let input = input.trim();
is clearer, because the name "input" always represents the same
concept, and it becomes impossible to inadvertently use the un-
trimmed input later. (One also might think of every "let" in a block
opening a kind of "new scope".)
Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote or quoted:
Of course, if this is a solved problem, a chapter in a book, or post on
Stack Overflow should be sufficient, but I thought to ask here first.
Since [language] already has [special feature implementation name], [feature],
there's little need to implement something
like this, unless as an exercise.
Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote or quoted:
the book talks about shadowing variables, with a completely new type.
The Rustafarians think that
let input = input.trim();
is clearer, because the name "input" always represents the same
concept, and it becomes impossible to inadvertently use the un-
trimmed input later. (One also might think of every "let" in a
block opening a kind of "new scope".)
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 76 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 55:41:11 |
| Calls: | 1,265 |
| Calls today: | 1 |
| Files: | 1,362 |
| D/L today: |
3 files (2,684K bytes) |
| Messages: | 285,687 |