Article View: comp.arch
Article #56Re: Optimization by programmers
From: Dan Cross
Date: Mon, 12 Oct 2026 15:47
Date: Mon, 12 Oct 2026 15:47
26 lines
1892 bytes
1892 bytes
In article <11ahs8q$38ir0$4@dont-email.me>, David Brown <david.brown@hesbynett.no> wrote: >[snip] >I think (and you will hopefully correct me if I am wrong!) in Rust if a >function receives a non-mutable reference as a parameter, it is not >allowed to cast it to a mutable reference. That is correct. There is no way to do that in safe Rust, and shenanigans that do it using unsafe are UB (UB in safe Rust is a compile-time error). As I mentioned in my other response, going the other direction is ok: it is possible to coerce a mutable reference to an immutable reference, so that you can e.g. invoke a method that takes `&self` on an object to which you have an `&mut` borrow. >> You can discuss if its a good idea to make non-mutability the default >> instead of the opposite. Personally I like that part. > >It certainly sounds good to me. It is! Being explicit about when things are mutable is very helpful. - Dan C.
Technical Details
Message-ID:
<11aivfc$87l$1@reader2.panix.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!panix!.POSTED.spitfire.i.gajendra.net!not-for-mailReferences:
<1177fdi$26ea4$1@dont-email.me> <1791742457-5857@newsgrouper.org> <11agm4p$2tfut$1@dont-email.me> <11ahs8q$38ir0$4@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!panix!.POSTED.spitfire.i.gajendra.net!not-for-mail From: cross@spitfire.i.gajendra.net (Dan Cross) Newsgroups: comp.arch Subject: Re: Optimization by programmers Date: Mon, 12 Oct 2026 15:47:56 -0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Message-ID: <11aivfc$87l$1@reader2.panix.com> References: <1177fdi$26ea4$1@dont-email.me> <1791742457-5857@newsgrouper.org> <11agm4p$2tfut$1@dont-email.me> <11ahs8q$38ir0$4@dont-email.me> Injection-Date: Mon, 12 Oct 2026 15:47:56 -0000 (UTC) Injection-Info: reader2.panix.com; posting-host="spitfire.i.gajendra.net:166.84.136.80"; logging-data="8437"; mail-complaints-to="abuse@panix.com" X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: cross@spitfire.i.gajendra.net (Dan Cross)