From 360dd6b83ecdd1f292e8ce9fe633b6a8e6047992 Mon Sep 17 00:00:00 2001 From: Adrian Rebola-Pardo <adrian.rebola@tuwien.ac.at> Date: Mon, 31 Mar 2025 09:44:40 +0200 Subject: [PATCH] added notes in unsafe-rust-is-cpp --- unsafe-rust-is-cpp/src/main.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/unsafe-rust-is-cpp/src/main.rs b/unsafe-rust-is-cpp/src/main.rs index f4e2b2d..573fbbc 100644 --- a/unsafe-rust-is-cpp/src/main.rs +++ b/unsafe-rust-is-cpp/src/main.rs @@ -36,6 +36,10 @@ pub fn rust_like_its_2025() { // So far this is the same. Let's move the rest to a function. println!("OUTPUT: {}", foo(n_mut1, n_mut2)); + // This works if you compile on debug. + // It also works if `foo` is hinted as never inlined. + // But it won't work anymore if non-inlined and compiled in release! + // You can't code in unsafe Rust like it's C++. // Unsafe Rust does not allow you to jump over the borrow rules. // It merely stops preventing you from trying. -- GitLab