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
158 views

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
19k views

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
362 views

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
759 views

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
663 views

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
12k views

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
3k views

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
5k views

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
232 views

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
2k views

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
338 views

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
560 views

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
246 views

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
2k views

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
902 views

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
391 views

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