﻿# upsert

> Insert or replace dotenv assignments

[Rust primitives](/docs/sdk/rust/primitives/)

```rust
dotenvx_primitives::upsert
```

## Usage

Preserves surrounding source formatting, quote style, and line endings. Accepts a slice of replacement values so duplicate assignments can be retained.

```rust
use dotenvx_primitives::upsert;

let updated = upsert(
    "HELLO=one\nHELLO=two",
    "HELLO",
    &["uno", "dos"],
)?;

assert_eq!(updated, "HELLO=uno\nHELLO=dos");
```
