Questions tagged [rust]

For questions about design of, or languages which are closely related to, Rust, a strongly-typed, memory-safe, expression-oriented language.

Filter by
Sorted by
Tagged with
1 vote
1 answer

Implementing automatic derivation without macros?

In Rust: #[derive(Display)] struct Foo<T>(T); If T conforms to the Display trait, ...
Jw C's user avatar
  • 131
35 votes
2 answers

Why do common Rust packages depend on C code?

Chapter 1 of "The Rust Programming Language" (Klabnik and Nichols) says: [S]ome common Rust packages depend on C code and will need a C compiler. Why do Rust packages have any dependency ...
StoneThrow's user avatar
10 votes
1 answer

What is the difference between GAT and HKT?

I implemented a basic generics-free, parameterless trait (type class) system. And I want to parameterize my trait system. The alternative paths I know of are Generic Associated Types (GAT) and Higher-...
Aster's user avatar
  • 2,688
13 votes
1 answer

Is there a difference between Rust's `macro_rules!` and Scheme's `syntax-rules`?

This is an example for the use of Rust's macro_rules!: ...
ceving's user avatar
  • 356
9 votes
1 answer

How does Rust parse ambiguous macros?

Rust's macros require them to be delimited by either parentheses, braces, or brackets, such as println!(arg) or foo! { bar, baz }...
Seggan's user avatar
  • 2,603
31 votes
3 answers

Why did Rust require macro names to have an exclamation point at the end?

Why did the designers of the Rust programming language require that macro names have to end with an exclamation point? I observe that both Common Lisp and Emacs Lisp language variants do not appear, ...
bgoodr's user avatar
  • 413
5 votes
4 answers

Creating a new language with Rust without Garbage Collection?

I am new to language development. I am aware of Rust's ownership model that builds programs in a way that does not need garbage collection. So if I am to build a new programming language using safe ...
M4X_'s user avatar
  • 153
17 votes
4 answers

Why does Rust choose not to provide `for` comprehensions?

Okay, so this might be a silly question. I'm a big fan of functional programming paradigms in higher-level scripting languages, so I'm probably using Rust wrong. However, I'm new to Rust and I'm ...
Philip Grabenhorst's user avatar
3 votes
1 answer

How can I design a Functor trait to handle trait?

In programming languages like Rust, variables of different types that implement the same trait can have different sizes, i.e., the number of bytes used in the memory representation of the type. For ...
Jw C's user avatar
  • 131
12 votes
4 answers

Why would a language have different error handling for libraries and applications?

Rust has two popular packages for augmenting its error handling: anyhow, for libraries, created by David Tolnay. thiserror, for applications, created by David Tolnay. They control how errors are ...
BoppreH's user avatar
  • 1,441
-1 votes
1 answer

Creating a high level language that transpiles to rust

I really like what Rust brings to the table, but I find it very difficult to work with if I am not really working on apps that require absolute speed and the lower-levelness e.g. specifying int sizes, ...
Ong Teck Wu's user avatar
11 votes
4 answers

Can a language allow raw pointer dereferencing while preserving memory safety?

In Rust, creating a raw pointer is allowed in safe code (i.e. outside of unsafe blocks), but then dereferencing it is unsafe: ...
mousetail's user avatar
  • 8,111
2 votes
3 answers

How should a language with period-based tuple indexing be parsed?

A few languages, most notably Rust, have tuple-indexing syntax that looks like this: tuple.0 // Access the first element of tuple This syntax is quite similar to ...
Ginger's user avatar
  • 2,579
12 votes
3 answers

Why does Rust have an infinite loop construct?

The Rust programming language has an infinite loop construct, which looks like this: loop { <some code> } It's the only language I can think of that has ...
Ginger's user avatar
  • 2,579
12 votes
3 answers

Is it possible to extend C to have the Rust concept of ownership for memory safety?

Rust has a number of memory safety features. Is it possible to extend or enhance C or C++ to also provide similar memory safety features instead of using workarounds such as the Valgrind tool suite?
James Risner's user avatar
11 votes
5 answers

What are the advantages of having first-class functions versus having only anonymous class with fancy sugars?

In Java, there are "SAM-interfaces" which are used as "types" for lambda expressions. In Haskell, there are dedicated types for functions. In Rust, there are no types for functions,...
ice1000's user avatar
  • 2,384