https://github.com/aweirddev/moving
Make elements of an array or a vector movable.
https://github.com/aweirddev/moving
ownership rust-ownership
Last synced: 5 months ago
JSON representation
Make elements of an array or a vector movable.
- Host: GitHub
- URL: https://github.com/aweirddev/moving
- Owner: AWeirdDev
- Created: 2025-07-13T09:09:48.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-07-13T09:18:44.000Z (11 months ago)
- Last Synced: 2025-07-13T09:26:15.733Z (11 months ago)
- Topics: ownership, rust-ownership
- Language: Rust
- Homepage: https://crates.io/crates/moving
- Size: 0 Bytes
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 📦 `moving`
Make elements of an array or a vector movable with some simple magic.
## Vec -> array
Move elements of a vector an array.
```rust
use moving::move_vec_to_array;
let v = vec![0, 1, 2, 3, 4]; // 5 items
let arr = move_vec_to_array::(v).unwrap();
assert_eq!(arr, [0, 1, 2, 3, 4]);
```
## Movable vectors
To make elements of an array or a vector movable, while the size is unknown, use `movable`:
```rust
use moving::{ MovableVec, movable };
let v = vec![0, 1, 2, 3, 4]; // 5 items
let arr = [0, 1, 2, 3, 4];
let mvv: MovableVec = movable(v);
let mvv_arr: MovableVec = movable(arr);
```
Alternatively, you can use `ToMovable`:
```rust
use moving::ToMovable;
some_vec.to_movable();
some_arr.to_movalbe();
```
## Movable arrays
To make elements of an array or a vector movable, while the size is known, use `nmovable` (notice the prefix "n"):
```rust
use moving::{ MovableArray, nmovable};
let v = vec![0, 1, 2, 3, 4]; // 5 items
let arr = [0, 1, 2, 3, 4];
let mvv: MovableArray = nmovable(v).unwrap();
let mvv_arr: MovableArray = nmovable(arr).unwrap();
```
Alternatively, you can use `ToNMovable`:
```rust
use moving::ToNMovable;
some_vec.to_nmovable()?;
some_arr.to_nmovable()?;
```