SShortSingh.
Back to feed

Rust Supports Custom Method Receivers Beyond &self and &mut self

0
·21 views

Rust's ownership system extends beyond the commonly used &self and &mut self method receivers to include arbitrary self types such as self: &Arc and self: &Mutex. These specialized receivers are rarely seen in everyday application code but become valuable when designing concurrent and multi-threaded systems. Standard receivers cover shared borrowing, exclusive mutable borrowing, and full ownership transfer, while arbitrary self types allow methods to directly require smart-pointer wrappers. For example, a method declared with self: &Arc can internally clone the Arc and spawn async tasks without the caller needing to handle the clone explicitly. This feature lets developers encode thread-safety requirements directly into method signatures, making concurrent Rust APIs more expressive and harder to misuse.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Salesforce Screen Flow Data Tables can now display Apex collections without a custom object

Starting with Winter '26 (API 65.0 and later), the Screen Flow Data Table accepts a collection of an Apex-defined type as its Source Collection. Developers designate a field as the Unique Identifier, which lets the table treat each item like a record that users can select and the flow can reuse. Display and row selection are supported now, but inline editing is not yet available. Previously, developers had to create mirror custom objects, insert and delete temporary records, use Transform elements, or build custom Lightning Web Components to achieve this. The article outlines the setup steps, including @AuraEnabled fields, an invocable wrapper class, and key selection guidance.

0
ProgrammingDEV Community ·

Compose Accessibility Testing: Catching Hidden Regressions in the Semantics Tree

A design system migration replaced IconButton usages with a new AppIconButton that silently dropped content descriptions, and the change passed compiler, screenshot, and unit checks. Accessibility regressions don't crash or alter pixels, so the article argues they must be caught by testing the semantics tree that TalkBack reads. The proposed fix is a required contentDescription parameter with no default, backed by layered tests. Those tests range from targeted assertions on high-risk nodes to bulk checks, touch-size validation, automated audits with Google's Accessibility Test Framework, and a short manual TalkBack routine. Tests should resolve labels from string resources rather than hard-coded text, so they remain valid when copy changes or the suite runs in other locales.

0
ProgrammingDEV Community ·

Biweekly Pay Schedules Bring Two Three-Paycheck Months in 2027, Spreadsheet Shows

A DEV Community tutorial explains how to identify the months that contain an extra paycheck for workers paid every two weeks or weekly. Such months occur because the calendar sometimes fits three paydays into a single month, so the exact months depend on a person's own first payday. The guide provides a spreadsheet template using standard date functions that works in Excel, Google Sheets and LibreOffice. Using an example with a January 8, 2027 payday and a $2,400 check, the workbook finds 26 paychecks for the year, with extra checks landing in April and October. The author recommends budgeting on the true monthly average rather than the base two-check amount to avoid shortfalls in lean months.

0
ProgrammingDEV Community ·

Lockstep v0.2.0 brings typed actors to Go, runnable in production and deterministic tests

Go provides goroutines and channels but leaves ownership of state, full-channel handling, panic recovery and testing to the developer. The lockstep library, an actor runtime for Go, released version 0.2.0 on 1 November 2026 to address these concerns. It offers typed messages, bounded mailboxes, supervision and timers, running actors on a pool of worker goroutines. The same actor code can run under go test in a simulation with its own clock and network, where a seed determines message ordering. The article builds a one-item shop actor that charges a card, reserving stock before the payment call to avoid races between concurrent buyers.