# Rust: error[E0282]: type annotations needed for `Vec<_>` / consider giving `x` an explicit type

**Code:** `E0282: type annotations needed` · **Category:** Rust · **Seen on:** Rust

The compiler can't infer a type from the available information.

## Meaning

Add a type annotation (`let v: Vec<i32> = Vec::new();`), use turbofish (`"5".parse::<i32>()`, `collect::<Vec<_>>()`), or give the value a use that fixes the type. Common with `collect()`, `parse()`, `Default::default()`, `into()` and empty collections.

## Common causes

- `collect()` without a target type
- `parse()` result unused/unspecified
- Empty `Vec::new()` never used with a type
- `.into()`/`Default::default()` ambiguous
- Closure params uninferred

## Quick fix

1. `let v: Vec<_> = iter.collect();`
2. `s.parse::<u32>()`
3. Annotate the variable/closure parameter

## Detailed fix by platform

### Rust

1. `let n = "42".parse::<i32>()?;`

## How to diagnose

1. **Site** — Where's the ambiguity?
2. **Fix** — Turbofish/annotation?
3. **Use** — Type fixed later?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/rust/e0282-type-annotations-needed)
