From a5b8094082ec5c033e976572fb5cf48309e5d6b1 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Fri, 19 Jul 2024 16:24:12 -0400 Subject: [PATCH] editor: Implement `From` instead of `Into` for converting `BlockId`s to `ElementId`s (#14839) This PR replaces the `Into for BlockId` implementation with `From 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 --- crates/editor/src/display_map/block_map.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index 630b96d50ca96ee300b6f22326ea3a3595582470..5302bfa73b60616665061114f4227be5361c9487 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -136,12 +136,12 @@ impl From for EntityId { } } -impl Into 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 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(), } } }