惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
博客园 - 三生石上(FineUI控件)
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MongoDB | Blog
MongoDB | Blog
小众软件
小众软件
Y
Y Combinator Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
D
Docker
罗磊的独立博客
Microsoft Security Blog
Microsoft Security Blog
D
DataBreaches.Net
B
Blog
Vercel News
Vercel News
Recent Announcements
Recent Announcements
GbyAI
GbyAI
阮一峰的网络日志
阮一峰的网络日志
T
The Blog of Author Tim Ferriss
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Proofpoint News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
宝玉的分享
宝玉的分享

Hacker News

GitHub - SeanFDZ/macmind: Single-layer transformer in HyperTalk for the classic Macintosh Show HN: Agent-cache – Multi-tier LLM/tool/session caching for Valkey and Redis Bonsai 1-bit WebGPU - a Hugging Face Space by webml-community Moving a large-scale metrics pipeline from StatsD to OpenTelemetry / Prometheus GitHub - Nightmare-Eclipse/RedSun: The Red Sun vulnerability repository GitHub - SethPyle376/hiraeth: Local AWS emulator focused on fast integration testing, with SQS support, SQLite-backed state, and a debug-friendly web UI. GitHub - macOS26/Agent: Any AI, replaces Claude Code, Cursor, OpenClaw. Over 18 LLM providers (Claude, OpenAI, Gemini, Ollama, Zai, HF, Qwen) wired into a native Mac app that writes code, builds Xcode projects, bumps versions, manages git, automates Safari, use AppleScript, JS or Accessibility, extend Agent! w/ MCP Servers, run tasks from your iPhone via Messages. YouTube now lets you turn off Shorts I Made a Terminal Pager Burgers | マクドナルド公式 Commands — HackerNews CLI documentation ChatGPT for Excel PiCore - Raspberry Pi Port of Tiny Core Linux Live Nation illegally monopolized ticketing market, jury finds Google Broke Its Promise to Me. Now ICE Has My Data. Founding Engineer at Adaptional | Y Combinator CRISPR takes important step toward silencing Down syndrome’s extra chromosome GitHub - saffron-health/libretto: The AI toolkit for building reliable browser automations US v. Heppner (S.D.N.Y. 2026) no attorney-client privilege for AI chats [pdf] Retrofitting JIT Compilers into C Interpreters IPv6 – Google The Accursèd Alphabetical Clock Cybersecurity Looks Like Proof of Work Now Fragments: April 14 Cal.com Goes Closed Source: Why AI Security Is Forcing Our Decision | Cal.com - Scheduling Software for Online Bookings Laravel raised money and now injects ads directly into your agent When moving fast, talking is the first thing to break Too much Discussion of the XOR swap trick – Heather Cafe Introduction to Spherical Harmonics for Graphics Programmers The Grand Line
turn_off_the_borrow_checker in you_can - Rust
2026-05-23 · via Hacker News

Attribute Macro turn_off_the_borrow_checker 

Source

#[turn_off_the_borrow_checker]
Expand description

You can’t “turn off the borrow checker” in Rust, and you shouldn’t want to. Rust’s references aren’t pointers, and the compiler is free to decimate code that tries to use references as though they are. If you need raw pointer behaviour in Rust, don’t use this, use Rust’s actual raw pointers, which don’t make the same aliasing guarantees to the compiler. However, if you would like to pretend the borrow checker doesn’t exist for educational purposes and never in production code, this macro that will suppress many (though not all) borrow checker errors in the code it’s applied to.

This shouldn’t break any otherwise-valid code; the borrow checker doesn’t affect compilation output, only verify input validity. However, it will allow unsound and unsafe nonsense that will fail unpredictably and dangerously. This is not safe to use.

§Example

§Without Macro

fn main() {
    let mut owned = vec![1, 32];

    let mut_1 = &mut owned[0];
    let mut_2 = &mut owned[1];
    //~^ ERROR cannot borrow `owned` as mutable more than once at a time

    drop(owned);
    //~^ ERROR cannot move out of `owned` because it is borrowed
    let undefined = *mut_1 + *mut_2;
    println!("{undefined}");
}
§With Macro
#[you_can::turn_off_the_borrow_checker]
fn main() {
    let mut owned = vec![1, 32];

    let mut_1 = &mut owned[0];
    let mut_2 = &mut owned[1];
    //~^ WARNING the borrow checker is suppressed for these references.

    drop(owned);
    let undefined = *mut_1 + *mut_2;
    println!("{undefined}");
}

§Explanation

The macro looks for references created in the code by use of the & or &mut operators or the ref and ref mut bindings, and wraps them with our borrow_unchecked() function to unbind their lifetimes, causing the borrow checker to effectively ignore them. If running on nightly, it adds new warning diagnostic messages for every reference it modifies.

§Expanded
fn main() {
    let mut owned = vec![1, 32];

    let mut_1 = unsafe { ::you_can::borrow_unchecked(&mut owned[0]) };
    let mut_2 = unsafe { ::you_can::borrow_unchecked(&mut owned[1]) };

    drop(owned);
    let undefined = *mut_1 + *mut_2;
    println!("{undefined}");
}

This approached is limited. It can’t suppress errors resulting from the code illegally composing lifetimes created elsewhere, or references created implicitly. As a workaround, prefixing &* can sometimes be used to force an explicit reference where one is needed, such as as in the example below.

§Example

#[you_can::turn_off_the_borrow_checker]
fn main() {
    let mut source = Some(1);
    let inner_mut = &*source.as_ref().unwrap();
    let mutable_alias = &mut source;

    source = None;
    *mutable_alias = Some(2);

    if let Some(ref mut inner_a) = source {
        match source {
            Some(ref mut inner_b) => {
                *inner_b = inner_mut + 1;
                *inner_a = inner_mut + 2;
            },
            None => {
                println!("none");
            },
        }
    }

    println!("{source:?}");
}
§Expanded
fn main() {
    let mut source = Some(1);
    let inner_mut = unsafe { ::you_can::borrow_unchecked(&*source.as_ref().unwrap()) };
    let mutable_alias = unsafe { ::you_can::borrow_unchecked(&mut source) };

    source = None;
    *mutable_alias = Some(2);

    if let Some(ref mut inner_a) = source {
        let inner_a = unsafe { ::you_can::borrow_unchecked(inner_a) };

        match source {
            Some(ref mut inner_b) => {
                let inner_b = unsafe { ::you_can::borrow_unchecked(inner_b) };

                *inner_b = inner_mut + 1;
                *inner_a = inner_mut + 2;
            },
            None => {
                println!("none");
            },
        }
    }

    println!("{source:?}");
}

§Discussions

Here are some related discussions, mostly about why you shouldn’t do this: