---
title: "Oxidizing OCaml: Rust-Style Ownership"
description: "Jane Street's OCaml extensions add Rust-style ownership through mode axes."
url: "https://swe.quest/articles/oxidizing-ocaml-rust-style-ownership-5670c1001a0b9cc2"
canonical: "https://blog.janestreet.com/oxidizing-ocaml-ownership/"
source: "Jane Street Tech Blog"
published: "2023-06-21"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 14
tags: ["functional-programming","type-systems","language-design","memory-management","rust"]
---

# Oxidizing OCaml: Rust-Style Ownership

A post on [Jane Street Tech Blog](https://swe.quest/sources/jane-street.md), published 2023-06-21, 14 min read, Deep dive. Original: [https://blog.janestreet.com/oxidizing-ocaml-ownership/](https://blog.janestreet.com/oxidizing-ocaml-ownership/)

## Summary

Jane Street's OCaml extensions add Rust-style ownership through mode axes. A uniqueness axis (unique, exclusive, shared) enables in-place functional updates, type-changing strong updates and safe resource APIs. Borrowing via \`&\` combines with locality so values can be lent without consuming them. Exclusively mutable fields give mutation without move semantics, and a linearity axis (once vs many) stops closures that capture unique values from being invoked twice, which would otherwise break type safety. Unlike Rust, these modes carry no lifetime variables, so they avoid higher-order polymorphism and don't interfere with type inference.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Functional programming](https://swe.quest/tags/functional-programming.md) (Languages)
- [Type systems](https://swe.quest/tags/type-systems.md) (Compilers & runtimes)
- [Language design](https://swe.quest/tags/language-design.md) (Compilers & runtimes)
- [Memory management](https://swe.quest/tags/memory-management.md) (Compilers & runtimes)
- [Rust](https://swe.quest/tags/rust.md) (Languages)

## Prerequisites

- OCaml syntax ([easy posts on Functional programming](https://swe.quest/tags/functional-programming.md?difficulty=easy))
- Rust ownership and borrowing ([easy posts on Rust](https://swe.quest/tags/rust.md?difficulty=easy))
- OCaml locality modes ([easy posts on Functional programming](https://swe.quest/tags/functional-programming.md?difficulty=easy))

## Keywords

OCaml, Rust, Jane Street, uniqueness modes, linearity, FnOnce

## Related posts

- [Oxidizing OCaml: Data Race Freedom](https://swe.quest/articles/oxidizing-ocaml-data-race-freedom-67442324c35f0e1c.md): Jane Street Tech Blog · 2023-09-01 · Hard · 15 min read · Functional programming, Type systems, Concurrency, Language design, Memory safety
  Jane Street's OCaml extensions use a new \`sync\` mode to make data races statically unrepresentable in multicore OCaml 5.
- [Oxidizing OCaml: Locality](https://swe.quest/articles/oxidizing-ocaml-locality-b1f7bf98d1488c18.md): Jane Street Tech Blog · 2023-05-26 · Hard · 13 min read · Functional programming, Type systems, Memory management, Language design, Compilers
  Jane Street is extending OCaml with modes, starting with a locality mode that marks values as local (cannot escape their region) or global, so the compiler can stack-allocate short-lived values while keeping garbage collection everywhere else.
- [ICFP 2024](https://swe.quest/articles/icfp-2024-a2b848db9d4cf383.md): Jane Street Tech Blog · 2024-08-29 · Hard · 8 min read · Functional programming, Type systems, Language design, Memory management, Compilers
  Jane Street's OCaml Language team brings nine papers and talks to ICFP 2024 and describes its compiler-branch extensions: modal types (modes like local and unique) for Rust-like control over allocation and data-race-free parallelism, and a kind system for unboxed layouts.
- [Using OxCaml to implement type-safe reference counting between OCaml and Python](https://swe.quest/articles/using-oxcaml-to-implement-type-safe-reference-counting-between-ocaml-and-python-6289aa53698f2fb6.md): Jane Street Tech Blog · 2026-06-15 · Hard · 12 min read · Functional programming, Memory management, Type systems, Python
  Wrapping Python objects as OCaml values in PyOCaml ties each object's release to the OCaml GC finalizer, so large data frames or GPU buffers can stay alive long after Python code drops them.
- [Autogenerating Rust-JS bindings with UniFFI](https://swe.quest/articles/autogenerating-rust-js-bindings-with-uniffi-bb58b4f2efeb71af.md): Mozilla Hacks · 2023-08-08 · Medium · 5 min read · Rust, JavaScript, Browsers, Concurrency
  Mozilla extended UniFFI, its Rust library for auto-generating foreign-language bindings, to emit JavaScript bindings for Firefox Desktop starting in Firefox 105, replacing error-prone hand-written wrappers that undermined Rust's memory safety.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
