Retrofitting Typestates into Rust

Research output: Chapter in Book/Report/Conference proceedingConference contributionpeer-review

1 Citation (Scopus)

Abstract

As software permeates our lives, bugs become increasingly expensive; the best way to reduce their cost is to reduce the number of bugs. Of course, this is easier said than done and, at best, we can go after their root causes to mitigate them. One of such causes is state, whether it is the state of a light bulb (i.e. on/off), or the state of a complex protocol, reasoning about state is a complex process which developers are required to do with subpar tools. Ideally, we want to specify constraints and have the computer reason for us; typestates enable developers to describe states using the type system and allow the compiler to reason about them. We propose an approach to bring typestates to Rust, without any external tools, leveraging only Rust's type and macro systems. Our approach provides a macro-based domain-specific language which enables developers to easily express and implement typestates, along with certain state machine safety guarantees, it is open-source and available at https://github.com/rustype/typestate-rs.

Original languageEnglish
Title of host publicationCBSOFT 2021 - Brazilian Conference on Software; Proceedings - 25th Brazilian Symposium on Programming Languages, SBLP 2021
PublisherAssociation for Computing Machinery
Pages83-91
Number of pages9
ISBN (Electronic)9781450390620
DOIs
Publication statusPublished - 27 Sep 2021
Event25th Brazilian Symposium on Programming Languages, SBLP 2021, held in conjunction with the Brazilian Conference on Software: Theory and Practice, CBSoft 2021 - Virtual, Online, Brazil
Duration: 27 Sep 20211 Oct 2021

Publication series

NameACM International Conference Proceeding Series

Conference

Conference25th Brazilian Symposium on Programming Languages, SBLP 2021, held in conjunction with the Brazilian Conference on Software: Theory and Practice, CBSoft 2021
Country/TerritoryBrazil
CityVirtual, Online
Period27/09/211/10/21

Keywords

  • Behavioral Typing
  • Domain-specific Languages
  • Macros
  • Protocol Compliance
  • Rust
  • Session Types
  • Typestates

Fingerprint

Dive into the research topics of 'Retrofitting Typestates into Rust'. Together they form a unique fingerprint.

Cite this