D
D
Daniil Demidko2016-08-03 12:43:23
Programming
Daniil Demidko, 2016-08-03 12:43:23

Weird Rust design?

I write if anything on the pluses, I recently tried Rust.
Design impressions are strange.
First, why are pointers called references in Rust?
A reference is an alias for a variable.
But in Rust, links take an address and work like pointers in pluses:

let var: i32 = 1;
let link: &i32 = & var; // &var - адрес var? Это ссылка или указатель?
println! ("{}", *link); // Ссылка с оператором разыменования?

And with all this, there are the usual C-style unsafe pointers:
let pointer: *const i32 = &var as *const i32;
unsafe { println! ("{}", *pointer); }

And if in the pros
int *const a=nullptr; // константный указатель
Then in Rust
let a: *const i32; // указатель на константу
Here's how to fit it - after the pros causes dislike.
Why call a pointer a reference?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Moseychuk, 2016-08-03
@Daniro_San

Rust is not C++. Why does he have to take terms from C++?
In Java, too, references are pointers in C++ terminology.
Moreover, a reference differs from a pointer only in abstraction. In memory, these will be the same cells containing the address.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question