# Migration Guide: 0.x to 1.0

This guide helps you migrate from `rok-utils` 0.x to 1.0.

## Overview

Version 1.0 freezes the public API. This release includes:
- `RokError` is now `#[non_exhaustive]`
- All public types implement `Send + Sync` where applicable
- MSRV is now 1.92

## Breaking Changes

### 1. `RokError` is `#[non_exhaustive]`

You can no longer exhaustively match on `RokError`:

```rust
// 0.x (allowed)
match err {
    RokError::NotFound(_) => ...,
    RokError::InvalidJson(_) => ...,
    // ... all variants
}

// 1.0 (requires wildcard)
match err {
    RokError::NotFound(_) => ...,
    RokError::InvalidJson(_) => ...,
    _ => ..., // required
}
```

### 2. `Lazy<T>` API Changes

The `Lazy` struct now uses `once_cell::sync::Lazy` internally:

```rust
// 0.x
let lazy = Lazy::new(|| 42);
assert!(lazy.is_initialized()); // removed

// 1.0
let lazy: Lazy<i32, fn() -> i32> = Lazy::new(|| 42);
let value = *lazy.get(); // returns &T instead of T
```

### 3. MSRV Bump

Minimum Supported Rust Version is now 1.92. Ensure your toolchain is up to date.

## New Features in 1.0

### Thread Safety

All public types now implement `Send + Sync` where applicable:

```rust
// Str is now Send + Sync
fn can_share_across_threads(s: Str) {
    let _ = s; // safe to send between threads
}

// Lazy<T> is now Send + Sync when T: Send + Sync
fn can_share_lazy_across_threads(lazy: Lazy<Config>) {
    let _ = lazy; // safe to share between threads
}
```

### GitHub Pages Documentation

API documentation is now hosted at:
```
https://ateeq1999.github.io/rok-utils/
```

Generate locally with:
```bash
cargo doc --all-features --no-deps
```

## Recommended Updates

### Update Your Cargo.toml

```toml
[dependencies]
rok-utils = "1.0"
```

### Update Rust Toolchain

Ensure MSRV compatibility:
```bash
rustup update
rustup default stable
```

### Update Error Handling

Add wildcard arm to prevent future breakage:

```rust
match error {
    RokError::NotFound(msg) => handle_not_found(msg),
    RokError::ValidationFailure { field, reason } => handle_validation(field, reason),
    _ => handle_internal_error(error),
}
```

## Deprecations

No deprecations in 1.0. All 0.x APIs remain available.

## Full Changelog

See [CHANGELOG.md](CHANGELOG.md) for detailed changes.
