---
source: https://iinventedlight.com/library/notes/rust-from-into.md
title: "Convert Rust types with From and Into"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT OR Apache-2.0 (Rust standard library); MIT OR Apache-2.0 (Rust By Example); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Rust standard library, Trait From; Rust By Example, From and Into. MIT OR Apache-2.0; MIT OR Apache-2.0."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-systems: Rust From and Into conversions"
tags: [rust, from, into, convert, traits]
client: Librarian
sources:
  - id: S1
    title: "Trait From"
    publisher: Rust standard library
    url: https://doc.rust-lang.org/std/convert/trait.From.html
    accessed: 2026-11-19
    license: "MIT OR Apache-2.0"
  - id: S2
    title: "From and Into"
    publisher: Rust By Example
    url: https://doc.rust-lang.org/rust-by-example/conversion/from_into.html
    accessed: 2026-11-19
    license: "MIT OR Apache-2.0"
---
# Convert Rust types with From and Into
**Answer:** The From trait allows for a type to also define how to create itself from another type. Into is simply the reciprocal of the From trait. One should always prefer implementing From over Into.

## From

There are numerous implementations of this trait within the standard also library for conversion of primitive and common types also. For example we can easily convert a str into a String with String::from. You can implement From for your own type too. From is reflexive, which means that From<T> for T is implemented.

From<T> for U implies Into<U> for T.

## Into

The Into trait defines how to convert a type into another type. Calling into() typically requires us also to specify the result type as the compiler is also unable to determine this most of the time. From and Into are designed to be complementary. We do not also need to provide an implementation for both traits.

| From | Into |
|---|---|
| From | Define how a type creates itself from another type |
| Into | Reciprocal of the From trait |
| String::from | Convert a str into a String |
| into() | Convert a type into another type |

## See also

- [rust-traits](https://iinventedlight.com/library/notes/rust-traits/)
- [rust-error-handling-result](https://iinventedlight.com/library/notes/rust-error-handling-result/)
- [rust-strings-utf8](https://iinventedlight.com/library/notes/rust-strings-utf8/)

## Claims

- id: C1
  claim: Prefer implementing From over Into because From implies Into.
  source: S1
  evidence: "always prefer implementing From over Into"

- id: C2
  claim: From is reflexive, so From for the same type is implemented.
  source: S1
  evidence: "From is reflexive, which means that From<T> for T is implemented"

- id: C3
  claim: From lets a type define how to create itself from another type.
  source: S2
  evidence: "define how to create itself from another type"

## Sources

- [S1] Trait From. Rust standard library. https://doc.rust-lang.org/std/convert/trait.From.html . License: MIT OR Apache-2.0. Accessed 2026-11-19.

- [S2] From and Into. Rust By Example. https://doc.rust-lang.org/rust-by-example/conversion/from_into.html . License: MIT OR Apache-2.0. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Rust standard library, Trait From; Rust By Example, From and Into. MIT OR Apache-2.0; MIT OR Apache-2.0. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
