editor: Implement From instead of Into for converting BlockIds to ElementIds (#14839)
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run

This PR replaces the `Into<ElementId> for BlockId` implementation with
`From<BlockId> for ElementId`.

This keeps in line with Rust's guidance for preferring implementing
`From`, and gives us more flexibility when converting.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-07-19 16:24:12 -04:00 committed by GitHub
parent d2efa12e16
commit a5b8094082
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -136,12 +136,12 @@ impl From<BlockId> for EntityId {
}
}
impl Into<ElementId> for BlockId {
fn into(self) -> ElementId {
match self {
Self::Custom(CustomBlockId(id)) => ("Block", id).into(),
Self::ExcerptHeader(id) => ("ExcerptHeader", EntityId::from(id)).into(),
Self::ExcerptFooter(id) => ("ExcerptFooter", EntityId::from(id)).into(),
impl From<BlockId> for ElementId {
fn from(value: BlockId) -> Self {
match value {
BlockId::Custom(CustomBlockId(id)) => ("Block", id).into(),
BlockId::ExcerptHeader(id) => ("ExcerptHeader", EntityId::from(id)).into(),
BlockId::ExcerptFooter(id) => ("ExcerptFooter", EntityId::from(id)).into(),
}
}
}