***
Wartungsfenster jeden ersten Mittwoch vormittag im Monat
***
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Rust Tutorial
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rebola Pardo, Adrian
Rust Tutorial
Commits
8b21b0de
Commit
8b21b0de
authored
1 month ago
by
Rebola Pardo, Adrian
Browse files
Options
Downloads
Patches
Plain Diff
now using the new &raw mut syntax
parent
dbb93297
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unsafe-rust-is-cpp/src/main.rs
+2
-2
2 additions, 2 deletions
unsafe-rust-is-cpp/src/main.rs
with
2 additions
and
2 deletions
unsafe-rust-is-cpp/src/main.rs
+
2
−
2
View file @
8b21b0de
...
@@ -9,7 +9,7 @@ pub fn rust_like_its_1985() {
...
@@ -9,7 +9,7 @@ pub fn rust_like_its_1985() {
let
mut
n
=
0
;
let
mut
n
=
0
;
// Taking a raw pointer is safe!
// Taking a raw pointer is safe!
let
n_ptr
=
&
mut
n
as
*
mut
i32
;
let
n_ptr
=
&
raw
mut
n
;
// Dereferencing a pointer is unsafe, but not necessarily UB.
// Dereferencing a pointer is unsafe, but not necessarily UB.
let
n_mut1
=
unsafe
{
&
mut
*
n_ptr
};
let
n_mut1
=
unsafe
{
&
mut
*
n_ptr
};
...
@@ -29,7 +29,7 @@ pub fn rust_like_its_1985() {
...
@@ -29,7 +29,7 @@ pub fn rust_like_its_1985() {
pub
fn
rust_like_its_2025
()
{
pub
fn
rust_like_its_2025
()
{
let
mut
n
=
0
;
let
mut
n
=
0
;
let
n_ptr
=
&
mut
n
as
*
mut
i32
;
let
n_ptr
=
&
raw
mut
n
;
let
n_mut1
=
unsafe
{
&
mut
*
n_ptr
};
let
n_mut1
=
unsafe
{
&
mut
*
n_ptr
};
let
n_mut2
=
unsafe
{
&
mut
*
n_ptr
};
let
n_mut2
=
unsafe
{
&
mut
*
n_ptr
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment