# gpui: Make create ElementId more easier from u64 \(\#64702\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/e9ddcdaf98294e335370e4f7566f80494d273bf2)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: e9ddcdaf98294e335370e4f7566f80494d273bf2

Requested commit: e9ddcdaf98294e335370e4f7566f80494d273bf2

Commit: e9ddcdaf98294e335370e4f7566f80494d273bf2

Tree: 3faa3aed0c6e7db655a67855aa8de80fb78db0c8

Author: Flin

Committer: GitHub

## Message

````
gpui: Make create ElementId more easier from u64 (#64702)

# Objective

Add `From<u64>` implementation for `ElementId` to reduce boilerplate
code.

## Solution

`ElementId` already implements `From<usize>`, but many call sites deal
with `u64` IDs directly (for example, list items backed by `u64`
identifiers). On 32-bit platforms, `usize` can truncate `u64` values,
and forcing callers to write `as u64` / `as usize` casts is both noisy
and error-prone.

This PR adds a symmetric `From<u64>` implementation, reusing the
existing `ElementId::Integer` variant:

```rust
impl From<u64> for ElementId {
    fn from(id: u64) -> Self {
        ElementId::Integer(id)
    }
}
```

The implementation lives in crates/gpui/src/window.rs, directly adjacent
to the existing `impl From <usize> for ElementId`, so the two stay in
sync. There is no new variant and no behavior change — this is purely an
ergonomics improvement.


## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- [GPUI] Impl From \<u64\> for ElementId
````

## Parents

- [3ab0b5df18031e19b0267b189969ef1a991cd352](https://git.cafe/gitcafe/zed/commit/3ab0b5df18031e19b0267b189969ef1a991cd352?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/e9ddcdaf98294e335370e4f7566f80494d273bf2?format=markdown)
