> ## Documentation Index
> Fetch the complete documentation index at: https://docs.starknet.io/llms.txt
> Use this file to discover all available pages before exploring further.

# core::starknet::storage::vec::VecTrait

Provides read-only access to elements in a storage [`Vec`](./core-starknet-storage-vec-Vec).
This trait enables retrieving elements and checking the vector's length without
modifying the underlying storage.

## Signature

```rust theme={null}
pub trait VecTrait
```

## Trait functions

### get

Returns a storage path to the element at the specified index, or `None` if out of bounds.

#### Signature

```rust theme={null}
fn get(self: T, index: u64) -> OptionElementType>>
```

#### Examples

```rust theme={null}
use starknet::storage::{Vec, VecTrait, StoragePointerReadAccess};

#[storage]
struct Storage {
    numbers: Vec,
}

fn maybe_number(self: @ContractState, index: u64) -> Option {
    self.numbers.get(index).map(|ptr| ptr.read())
}
```

### at

Returns a storage path to access the element at the specified index.

#### Panics

Panics if the index is out of bounds.

#### Examples

```rust theme={null}
use starknet::storage::{Vec, VecTrait, StoragePointerReadAccess};

#[storage]
struct Storage {
    numbers: Vec,
}

fn get_number(self: @ContractState, index: u64) -> u256 {
    self.numbers.at(index).read()
}
```

#### Signature

```rust theme={null}
fn at(self: T, index: u64) -> StoragePathElementType>
```

### len

Returns the number of elements in the vector.
The length is stored at the vector's base storage address and is automatically
updated when elements are appended.

#### Signature

```rust theme={null}
fn len(self: T) -> u64
```

#### Examples

```rust theme={null}
use starknet::storage::{Vec, VecTrait};

#[storage]
struct Storage {
    numbers: Vec,
}

fn is_empty(self: @ContractState) -> bool {
    self.numbers.len() == 0
}
```

## Trait types

### ElementType

#### Signature

```rust theme={null}
type ElementType;
```
