dap: Make `ProtoConversion::to_proto` consume `self` (#47871)

tidely created

Closes #ISSUE

Make `ProtoConversion::to_proto` consume `self`. We never create more
than one `proto` type out of a single `dap` type, meaning having the
conversation be non-consuming has no benefits, while consuming allows us
to remove a bunch of clones.

Release Notes:

- N/A *or* Added/Fixed/Improved ...

Change summary

crates/dap/src/proto_conversions.rs | 367 ++++++++++++++----------------
1 file changed, 177 insertions(+), 190 deletions(-)

Detailed changes

crates/dap/src/proto_conversions.rs 🔗

@@ -9,7 +9,7 @@ pub trait ProtoConversion {
     type ProtoType;
     type Output;
 
-    fn to_proto(&self) -> Self::ProtoType;
+    fn to_proto(self) -> Self::ProtoType;
     fn from_proto(payload: Self::ProtoType) -> Self::Output;
 }
 
@@ -20,8 +20,8 @@ where
     type ProtoType = Vec<T::ProtoType>;
     type Output = Self;
 
-    fn to_proto(&self) -> Self::ProtoType {
-        self.iter().map(|item| item.to_proto()).collect()
+    fn to_proto(self) -> Self::ProtoType {
+        self.into_iter().map(|item| item.to_proto()).collect()
     }
 
     fn from_proto(payload: Self::ProtoType) -> Self {
@@ -36,18 +36,15 @@ impl ProtoConversion for dap_types::Scope {
     type ProtoType = DapScope;
     type Output = Self;
 
-    fn to_proto(&self) -> Self::ProtoType {
+    fn to_proto(self) -> Self::ProtoType {
         Self::ProtoType {
-            name: self.name.clone(),
-            presentation_hint: self
-                .presentation_hint
-                .as_ref()
-                .map(|hint| hint.to_proto().into()),
+            name: self.name,
+            presentation_hint: self.presentation_hint.map(|hint| hint.to_proto().into()),
             variables_reference: self.variables_reference,
             named_variables: self.named_variables,
             indexed_variables: self.indexed_variables,
             expensive: self.expensive,
-            source: self.source.as_ref().map(Source::to_proto),
+            source: self.source.map(Source::to_proto),
             line: self.line,
             end_line: self.end_line,
             column: self.column,
@@ -79,16 +76,16 @@ impl ProtoConversion for dap_types::Variable {
     type ProtoType = DapVariable;
     type Output = Self;
 
-    fn to_proto(&self) -> Self::ProtoType {
+    fn to_proto(self) -> Self::ProtoType {
         Self::ProtoType {
-            name: self.name.clone(),
-            value: self.value.clone(),
-            r#type: self.type_.clone(),
-            evaluate_name: self.evaluate_name.clone(),
+            name: self.name,
+            value: self.value,
+            r#type: self.type_,
+            evaluate_name: self.evaluate_name,
             variables_reference: self.variables_reference,
             named_variables: self.named_variables,
             indexed_variables: self.indexed_variables,
-            memory_reference: self.memory_reference.clone(),
+            memory_reference: self.memory_reference,
         }
     }
 
@@ -113,24 +110,24 @@ impl ProtoConversion for dap_types::ScopePresentationHint {
     type ProtoType = DapScopePresentationHint;
     type Output = Self;
 
-    fn to_proto(&self) -> Self::ProtoType {
+    fn to_proto(self) -> Self::ProtoType {
         match self {
-            dap_types::ScopePresentationHint::Locals => DapScopePresentationHint::Locals,
-            dap_types::ScopePresentationHint::Arguments => DapScopePresentationHint::Arguments,
-            dap_types::ScopePresentationHint::Registers => DapScopePresentationHint::Registers,
-            dap_types::ScopePresentationHint::ReturnValue => DapScopePresentationHint::ReturnValue,
-            dap_types::ScopePresentationHint::Unknown => DapScopePresentationHint::ScopeUnknown,
-            &_ => unreachable!(),
+            Self::Locals => Self::ProtoType::Locals,
+            Self::Arguments => Self::ProtoType::Arguments,
+            Self::Registers => Self::ProtoType::Registers,
+            Self::ReturnValue => Self::ProtoType::ReturnValue,
+            Self::Unknown => Self::ProtoType::ScopeUnknown,
+            _ => unreachable!(),
         }
     }
 
     fn from_proto(payload: Self::ProtoType) -> Self {
         match payload {
-            DapScopePresentationHint::Locals => dap_types::ScopePresentationHint::Locals,
-            DapScopePresentationHint::Arguments => dap_types::ScopePresentationHint::Arguments,
-            DapScopePresentationHint::Registers => dap_types::ScopePresentationHint::Registers,
-            DapScopePresentationHint::ReturnValue => dap_types::ScopePresentationHint::ReturnValue,
-            DapScopePresentationHint::ScopeUnknown => dap_types::ScopePresentationHint::Unknown,
+            Self::ProtoType::Locals => Self::Locals,
+            Self::ProtoType::Arguments => Self::Arguments,
+            Self::ProtoType::Registers => Self::Registers,
+            Self::ProtoType::ReturnValue => Self::ReturnValue,
+            Self::ProtoType::ScopeUnknown => Self::Unknown,
         }
     }
 }
@@ -139,25 +136,21 @@ impl ProtoConversion for dap_types::SourcePresentationHint {
     type ProtoType = DapSourcePresentationHint;
     type Output = Self;
 
-    fn to_proto(&self) -> Self::ProtoType {
+    fn to_proto(self) -> Self::ProtoType {
         match self {
-            dap_types::SourcePresentationHint::Normal => DapSourcePresentationHint::SourceNormal,
-            dap_types::SourcePresentationHint::Emphasize => DapSourcePresentationHint::Emphasize,
-            dap_types::SourcePresentationHint::Deemphasize => {
-                DapSourcePresentationHint::Deemphasize
-            }
-            dap_types::SourcePresentationHint::Unknown => DapSourcePresentationHint::SourceUnknown,
+            Self::Normal => Self::ProtoType::SourceNormal,
+            Self::Emphasize => Self::ProtoType::Emphasize,
+            Self::Deemphasize => Self::ProtoType::Deemphasize,
+            Self::Unknown => Self::ProtoType::SourceUnknown,
         }
     }
 
     fn from_proto(payload: Self::ProtoType) -> Self {
         match payload {
-            DapSourcePresentationHint::SourceNormal => dap_types::SourcePresentationHint::Normal,
-            DapSourcePresentationHint::Emphasize => dap_types::SourcePresentationHint::Emphasize,
-            DapSourcePresentationHint::Deemphasize => {
-                dap_types::SourcePresentationHint::Deemphasize
-            }
-            DapSourcePresentationHint::SourceUnknown => dap_types::SourcePresentationHint::Unknown,
+            Self::ProtoType::SourceNormal => Self::Normal,
+            Self::ProtoType::Emphasize => Self::Emphasize,
+            Self::ProtoType::Deemphasize => Self::Deemphasize,
+            Self::ProtoType::SourceUnknown => Self::Unknown,
         }
     }
 }
@@ -166,10 +159,10 @@ impl ProtoConversion for dap_types::Checksum {
     type ProtoType = DapChecksum;
     type Output = Self;
 
-    fn to_proto(&self) -> Self::ProtoType {
+    fn to_proto(self) -> Self::ProtoType {
         DapChecksum {
             algorithm: self.algorithm.to_proto().into(),
-            checksum: self.checksum.clone(),
+            checksum: self.checksum,
         }
     }
 
@@ -185,22 +178,22 @@ impl ProtoConversion for dap_types::ChecksumAlgorithm {
     type ProtoType = DapChecksumAlgorithm;
     type Output = Self;
 
-    fn to_proto(&self) -> Self::ProtoType {
+    fn to_proto(self) -> Self::ProtoType {
         match self {
-            dap_types::ChecksumAlgorithm::Md5 => DapChecksumAlgorithm::Md5,
-            dap_types::ChecksumAlgorithm::Sha1 => DapChecksumAlgorithm::Sha1,
-            dap_types::ChecksumAlgorithm::Sha256 => DapChecksumAlgorithm::Sha256,
-            dap_types::ChecksumAlgorithm::Timestamp => DapChecksumAlgorithm::Timestamp,
+            Self::Md5 => DapChecksumAlgorithm::Md5,
+            Self::Sha1 => DapChecksumAlgorithm::Sha1,
+            Self::Sha256 => DapChecksumAlgorithm::Sha256,
+            Self::Timestamp => DapChecksumAlgorithm::Timestamp,
         }
     }
 
     fn from_proto(payload: Self::ProtoType) -> Self {
         match payload {
-            DapChecksumAlgorithm::Md5 => dap_types::ChecksumAlgorithm::Md5,
-            DapChecksumAlgorithm::Sha1 => dap_types::ChecksumAlgorithm::Sha1,
-            DapChecksumAlgorithm::Sha256 => dap_types::ChecksumAlgorithm::Sha256,
-            DapChecksumAlgorithm::Timestamp => dap_types::ChecksumAlgorithm::Timestamp,
-            DapChecksumAlgorithm::ChecksumAlgorithmUnspecified => unreachable!(),
+            Self::ProtoType::Md5 => Self::Md5,
+            Self::ProtoType::Sha1 => Self::Sha1,
+            Self::ProtoType::Sha256 => Self::Sha256,
+            Self::ProtoType::Timestamp => Self::Timestamp,
+            Self::ProtoType::ChecksumAlgorithmUnspecified => unreachable!(),
         }
     }
 }
@@ -209,37 +202,29 @@ impl ProtoConversion for dap_types::Source {
     type ProtoType = DapSource;
     type Output = Self;
 
-    fn to_proto(&self) -> Self::ProtoType {
+    fn to_proto(self) -> Self::ProtoType {
         Self::ProtoType {
-            name: self.name.clone(),
-            path: self.path.clone(),
+            name: self.name,
+            path: self.path,
             source_reference: self.source_reference,
             presentation_hint: self.presentation_hint.map(|hint| hint.to_proto().into()),
-            origin: self.origin.clone(),
-            sources: self
-                .sources
-                .clone()
-                .map(|src| src.to_proto())
-                .unwrap_or_default(),
+            origin: self.origin,
+            sources: self.sources.map(|src| src.to_proto()).unwrap_or_default(),
             adapter_data: Default::default(), // TODO Debugger Collab
-            checksums: self
-                .checksums
-                .clone()
-                .map(|c| c.to_proto())
-                .unwrap_or_default(),
+            checksums: self.checksums.map(|c| c.to_proto()).unwrap_or_default(),
         }
     }
 
     fn from_proto(payload: Self::ProtoType) -> Self {
         Self {
-            name: payload.name.clone(),
-            path: payload.path.clone(),
+            name: payload.name,
+            path: payload.path,
             source_reference: payload.source_reference,
             presentation_hint: payload
                 .presentation_hint
                 .and_then(DapSourcePresentationHint::from_i32)
                 .map(dap_types::SourcePresentationHint::from_proto),
-            origin: payload.origin.clone(),
+            origin: payload.origin,
             sources: Some(Vec::<dap_types::Source>::from_proto(payload.sources)),
             checksums: Some(Vec::<dap_types::Checksum>::from_proto(payload.checksums)),
             adapter_data: None, // TODO Debugger Collab
@@ -251,17 +236,17 @@ impl ProtoConversion for dap_types::StackFrame {
     type ProtoType = DapStackFrame;
     type Output = Self;
 
-    fn to_proto(&self) -> Self::ProtoType {
+    fn to_proto(self) -> Self::ProtoType {
         Self::ProtoType {
             id: self.id,
             name: self.name.clone(),
-            source: self.source.as_ref().map(|src| src.to_proto()),
+            source: self.source.map(|src| src.to_proto()),
             line: self.line,
             column: self.column,
             end_line: self.end_line,
             end_column: self.end_column,
             can_restart: self.can_restart,
-            instruction_pointer_reference: self.instruction_pointer_reference.clone(),
+            instruction_pointer_reference: self.instruction_pointer_reference,
             module_id: None,         // TODO Debugger Collab
             presentation_hint: None, // TODO Debugger Collab
         }
@@ -284,27 +269,43 @@ impl ProtoConversion for dap_types::StackFrame {
     }
 }
 
+impl ProtoConversion for dap_types::ModuleId {
+    type ProtoType = proto::dap_module_id::Id;
+    type Output = Self;
+
+    fn to_proto(self) -> Self::ProtoType {
+        match self {
+            Self::Number(num) => Self::ProtoType::Number(num),
+            Self::String(string) => Self::ProtoType::String(string),
+        }
+    }
+
+    fn from_proto(payload: Self::ProtoType) -> Self::Output {
+        match payload {
+            Self::ProtoType::Number(num) => Self::Number(num),
+            Self::ProtoType::String(string) => Self::String(string),
+        }
+    }
+}
+
 impl ProtoConversion for dap_types::Module {
     type ProtoType = DapModule;
     type Output = Result<Self>;
 
-    fn to_proto(&self) -> Self::ProtoType {
-        let id = match &self.id {
-            dap_types::ModuleId::Number(num) => proto::dap_module_id::Id::Number(*num),
-            dap_types::ModuleId::String(string) => proto::dap_module_id::Id::String(string.clone()),
-        };
-
+    fn to_proto(self) -> Self::ProtoType {
         DapModule {
-            id: Some(proto::DapModuleId { id: Some(id) }),
-            name: self.name.clone(),
-            path: self.path.clone(),
+            id: Some(proto::DapModuleId {
+                id: Some(self.id.to_proto()),
+            }),
+            name: self.name,
+            path: self.path,
             is_optimized: self.is_optimized,
             is_user_code: self.is_user_code,
-            version: self.version.clone(),
-            symbol_status: self.symbol_status.clone(),
-            symbol_file_path: self.symbol_file_path.clone(),
-            date_time_stamp: self.date_time_stamp.clone(),
-            address_range: self.address_range.clone(),
+            version: self.version,
+            symbol_status: self.symbol_status,
+            symbol_file_path: self.symbol_file_path,
+            date_time_stamp: self.date_time_stamp,
+            address_range: self.address_range,
         }
     }
 
@@ -338,19 +339,19 @@ impl ProtoConversion for dap_types::SteppingGranularity {
     type ProtoType = proto::SteppingGranularity;
     type Output = Self;
 
-    fn to_proto(&self) -> Self::ProtoType {
+    fn to_proto(self) -> Self::ProtoType {
         match self {
-            dap_types::SteppingGranularity::Statement => proto::SteppingGranularity::Statement,
-            dap_types::SteppingGranularity::Line => proto::SteppingGranularity::Line,
-            dap_types::SteppingGranularity::Instruction => proto::SteppingGranularity::Instruction,
+            Self::Statement => Self::ProtoType::Statement,
+            Self::Line => Self::ProtoType::Line,
+            Self::Instruction => Self::ProtoType::Instruction,
         }
     }
 
     fn from_proto(payload: Self::ProtoType) -> Self {
         match payload {
-            proto::SteppingGranularity::Line => dap_types::SteppingGranularity::Line,
-            proto::SteppingGranularity::Instruction => dap_types::SteppingGranularity::Instruction,
-            proto::SteppingGranularity::Statement => dap_types::SteppingGranularity::Statement,
+            Self::ProtoType::Line => Self::Line,
+            Self::ProtoType::Instruction => Self::Instruction,
+            Self::ProtoType::Statement => Self::Statement,
         }
     }
 }
@@ -359,23 +360,23 @@ impl ProtoConversion for dap_types::OutputEventCategory {
     type ProtoType = proto::DapOutputCategory;
     type Output = Self;
 
-    fn to_proto(&self) -> Self::ProtoType {
+    fn to_proto(self) -> Self::ProtoType {
         match self {
-            Self::Console => proto::DapOutputCategory::ConsoleOutput,
-            Self::Important => proto::DapOutputCategory::Important,
-            Self::Stdout => proto::DapOutputCategory::Stdout,
-            Self::Stderr => proto::DapOutputCategory::Stderr,
-            _ => proto::DapOutputCategory::Unknown,
+            Self::Console => Self::ProtoType::ConsoleOutput,
+            Self::Important => Self::ProtoType::Important,
+            Self::Stdout => Self::ProtoType::Stdout,
+            Self::Stderr => Self::ProtoType::Stderr,
+            _ => Self::ProtoType::Unknown,
         }
     }
 
     fn from_proto(payload: Self::ProtoType) -> Self {
         match payload {
-            proto::DapOutputCategory::ConsoleOutput => Self::Console,
-            proto::DapOutputCategory::Important => Self::Important,
-            proto::DapOutputCategory::Stdout => Self::Stdout,
-            proto::DapOutputCategory::Stderr => Self::Stderr,
-            proto::DapOutputCategory::Unknown => Self::Unknown,
+            Self::ProtoType::ConsoleOutput => Self::Console,
+            Self::ProtoType::Important => Self::Important,
+            Self::ProtoType::Stdout => Self::Stdout,
+            Self::ProtoType::Stderr => Self::Stderr,
+            Self::ProtoType::Unknown => Self::Unknown,
         }
     }
 }
@@ -384,15 +385,12 @@ impl ProtoConversion for dap_types::OutputEvent {
     type ProtoType = proto::DapOutputEvent;
     type Output = Self;
 
-    fn to_proto(&self) -> Self::ProtoType {
-        proto::DapOutputEvent {
-            category: self
-                .category
-                .as_ref()
-                .map(|category| category.to_proto().into()),
+    fn to_proto(self) -> Self::ProtoType {
+        Self::ProtoType {
+            category: self.category.map(|category| category.to_proto().into()),
             output: self.output.clone(),
             variables_reference: self.variables_reference,
-            source: self.source.as_ref().map(|source| source.to_proto()),
+            source: self.source.map(|source| source.to_proto()),
             line: self.line.map(|line| line as u32),
             column: self.column.map(|column| column as u32),
             group: self.group.map(|group| group.to_proto().into()),
@@ -400,12 +398,12 @@ impl ProtoConversion for dap_types::OutputEvent {
     }
 
     fn from_proto(payload: Self::ProtoType) -> Self {
-        dap_types::OutputEvent {
+        Self {
             category: payload
                 .category
                 .and_then(proto::DapOutputCategory::from_i32)
                 .map(OutputEventCategory::from_proto),
-            output: payload.output.clone(),
+            output: payload.output,
             variables_reference: payload.variables_reference,
             source: payload.source.map(Source::from_proto),
             line: payload.line.map(|line| line as u64),
@@ -424,21 +422,19 @@ impl ProtoConversion for dap_types::OutputEventGroup {
     type ProtoType = proto::DapOutputEventGroup;
     type Output = Self;
 
-    fn to_proto(&self) -> Self::ProtoType {
+    fn to_proto(self) -> Self::ProtoType {
         match self {
-            dap_types::OutputEventGroup::Start => proto::DapOutputEventGroup::Start,
-            dap_types::OutputEventGroup::StartCollapsed => {
-                proto::DapOutputEventGroup::StartCollapsed
-            }
-            dap_types::OutputEventGroup::End => proto::DapOutputEventGroup::End,
+            Self::Start => Self::ProtoType::Start,
+            Self::StartCollapsed => Self::ProtoType::StartCollapsed,
+            Self::End => Self::ProtoType::End,
         }
     }
 
     fn from_proto(payload: Self::ProtoType) -> Self {
         match payload {
-            proto::DapOutputEventGroup::Start => Self::Start,
-            proto::DapOutputEventGroup::StartCollapsed => Self::StartCollapsed,
-            proto::DapOutputEventGroup::End => Self::End,
+            Self::ProtoType::Start => Self::Start,
+            Self::ProtoType::StartCollapsed => Self::StartCollapsed,
+            Self::ProtoType::End => Self::End,
         }
     }
 }
@@ -447,21 +443,20 @@ impl ProtoConversion for dap_types::CompletionItem {
     type ProtoType = proto::DapCompletionItem;
     type Output = Self;
 
-    fn to_proto(&self) -> Self::ProtoType {
-        proto::DapCompletionItem {
+    fn to_proto(self) -> Self::ProtoType {
+        Self::ProtoType {
             label: self.label.clone(),
             text: self.text.clone(),
             detail: self.detail.clone(),
             typ: self
                 .type_
-                .as_ref()
                 .map(ProtoConversion::to_proto)
                 .map(|typ| typ.into()),
             start: self.start,
             length: self.length,
             selection_start: self.selection_start,
             selection_length: self.selection_length,
-            sort_text: self.sort_text.clone(),
+            sort_text: self.sort_text,
         }
     }
 
@@ -486,34 +481,26 @@ impl ProtoConversion for dap_types::EvaluateArgumentsContext {
     type ProtoType = DapEvaluateContext;
     type Output = Self;
 
-    fn to_proto(&self) -> Self::ProtoType {
+    fn to_proto(self) -> Self::ProtoType {
         match self {
-            dap_types::EvaluateArgumentsContext::Variables => {
-                proto::DapEvaluateContext::EvaluateVariables
-            }
-            dap_types::EvaluateArgumentsContext::Watch => proto::DapEvaluateContext::Watch,
-            dap_types::EvaluateArgumentsContext::Hover => proto::DapEvaluateContext::Hover,
-            dap_types::EvaluateArgumentsContext::Repl => proto::DapEvaluateContext::Repl,
-            dap_types::EvaluateArgumentsContext::Clipboard => proto::DapEvaluateContext::Clipboard,
-            dap_types::EvaluateArgumentsContext::Unknown => {
-                proto::DapEvaluateContext::EvaluateUnknown
-            }
-            _ => proto::DapEvaluateContext::EvaluateUnknown,
+            Self::Variables => Self::ProtoType::EvaluateVariables,
+            Self::Watch => Self::ProtoType::Watch,
+            Self::Hover => Self::ProtoType::Hover,
+            Self::Repl => Self::ProtoType::Repl,
+            Self::Clipboard => Self::ProtoType::Clipboard,
+            Self::Unknown => Self::ProtoType::EvaluateUnknown,
+            _ => Self::ProtoType::EvaluateUnknown,
         }
     }
 
     fn from_proto(payload: Self::ProtoType) -> Self {
         match payload {
-            proto::DapEvaluateContext::EvaluateVariables => {
-                dap_types::EvaluateArgumentsContext::Variables
-            }
-            proto::DapEvaluateContext::Watch => dap_types::EvaluateArgumentsContext::Watch,
-            proto::DapEvaluateContext::Hover => dap_types::EvaluateArgumentsContext::Hover,
-            proto::DapEvaluateContext::Repl => dap_types::EvaluateArgumentsContext::Repl,
-            proto::DapEvaluateContext::Clipboard => dap_types::EvaluateArgumentsContext::Clipboard,
-            proto::DapEvaluateContext::EvaluateUnknown => {
-                dap_types::EvaluateArgumentsContext::Unknown
-            }
+            Self::ProtoType::EvaluateVariables => Self::Variables,
+            Self::ProtoType::Watch => Self::Watch,
+            Self::ProtoType::Hover => Self::Hover,
+            Self::ProtoType::Repl => Self::Repl,
+            Self::ProtoType::Clipboard => Self::Clipboard,
+            Self::ProtoType::EvaluateUnknown => Self::Unknown,
         }
     }
 }
@@ -522,51 +509,51 @@ impl ProtoConversion for dap_types::CompletionItemType {
     type ProtoType = proto::DapCompletionItemType;
     type Output = Self;
 
-    fn to_proto(&self) -> Self::ProtoType {
+    fn to_proto(self) -> Self::ProtoType {
         match self {
-            dap_types::CompletionItemType::Class => proto::DapCompletionItemType::Class,
-            dap_types::CompletionItemType::Color => proto::DapCompletionItemType::Color,
-            dap_types::CompletionItemType::Constructor => proto::DapCompletionItemType::Constructor,
-            dap_types::CompletionItemType::Customcolor => proto::DapCompletionItemType::Customcolor,
-            dap_types::CompletionItemType::Enum => proto::DapCompletionItemType::Enum,
-            dap_types::CompletionItemType::Field => proto::DapCompletionItemType::Field,
-            dap_types::CompletionItemType::File => proto::DapCompletionItemType::CompletionItemFile,
-            dap_types::CompletionItemType::Function => proto::DapCompletionItemType::Function,
-            dap_types::CompletionItemType::Interface => proto::DapCompletionItemType::Interface,
-            dap_types::CompletionItemType::Keyword => proto::DapCompletionItemType::Keyword,
-            dap_types::CompletionItemType::Method => proto::DapCompletionItemType::Method,
-            dap_types::CompletionItemType::Module => proto::DapCompletionItemType::Module,
-            dap_types::CompletionItemType::Property => proto::DapCompletionItemType::Property,
-            dap_types::CompletionItemType::Reference => proto::DapCompletionItemType::Reference,
-            dap_types::CompletionItemType::Snippet => proto::DapCompletionItemType::Snippet,
-            dap_types::CompletionItemType::Text => proto::DapCompletionItemType::Text,
-            dap_types::CompletionItemType::Unit => proto::DapCompletionItemType::Unit,
-            dap_types::CompletionItemType::Value => proto::DapCompletionItemType::Value,
-            dap_types::CompletionItemType::Variable => proto::DapCompletionItemType::Variable,
+            Self::Class => Self::ProtoType::Class,
+            Self::Color => Self::ProtoType::Color,
+            Self::Constructor => Self::ProtoType::Constructor,
+            Self::Customcolor => Self::ProtoType::Customcolor,
+            Self::Enum => Self::ProtoType::Enum,
+            Self::Field => Self::ProtoType::Field,
+            Self::File => Self::ProtoType::CompletionItemFile,
+            Self::Function => Self::ProtoType::Function,
+            Self::Interface => Self::ProtoType::Interface,
+            Self::Keyword => Self::ProtoType::Keyword,
+            Self::Method => Self::ProtoType::Method,
+            Self::Module => Self::ProtoType::Module,
+            Self::Property => Self::ProtoType::Property,
+            Self::Reference => Self::ProtoType::Reference,
+            Self::Snippet => Self::ProtoType::Snippet,
+            Self::Text => Self::ProtoType::Text,
+            Self::Unit => Self::ProtoType::Unit,
+            Self::Value => Self::ProtoType::Value,
+            Self::Variable => Self::ProtoType::Variable,
         }
     }
 
     fn from_proto(payload: Self::ProtoType) -> Self {
         match payload {
-            proto::DapCompletionItemType::Class => dap_types::CompletionItemType::Class,
-            proto::DapCompletionItemType::Color => dap_types::CompletionItemType::Color,
-            proto::DapCompletionItemType::CompletionItemFile => dap_types::CompletionItemType::File,
-            proto::DapCompletionItemType::Constructor => dap_types::CompletionItemType::Constructor,
-            proto::DapCompletionItemType::Customcolor => dap_types::CompletionItemType::Customcolor,
-            proto::DapCompletionItemType::Enum => dap_types::CompletionItemType::Enum,
-            proto::DapCompletionItemType::Field => dap_types::CompletionItemType::Field,
-            proto::DapCompletionItemType::Function => dap_types::CompletionItemType::Function,
-            proto::DapCompletionItemType::Interface => dap_types::CompletionItemType::Interface,
-            proto::DapCompletionItemType::Keyword => dap_types::CompletionItemType::Keyword,
-            proto::DapCompletionItemType::Method => dap_types::CompletionItemType::Method,
-            proto::DapCompletionItemType::Module => dap_types::CompletionItemType::Module,
-            proto::DapCompletionItemType::Property => dap_types::CompletionItemType::Property,
-            proto::DapCompletionItemType::Reference => dap_types::CompletionItemType::Reference,
-            proto::DapCompletionItemType::Snippet => dap_types::CompletionItemType::Snippet,
-            proto::DapCompletionItemType::Text => dap_types::CompletionItemType::Text,
-            proto::DapCompletionItemType::Unit => dap_types::CompletionItemType::Unit,
-            proto::DapCompletionItemType::Value => dap_types::CompletionItemType::Value,
-            proto::DapCompletionItemType::Variable => dap_types::CompletionItemType::Variable,
+            Self::ProtoType::Class => Self::Class,
+            Self::ProtoType::Color => Self::Color,
+            Self::ProtoType::CompletionItemFile => Self::File,
+            Self::ProtoType::Constructor => Self::Constructor,
+            Self::ProtoType::Customcolor => Self::Customcolor,
+            Self::ProtoType::Enum => Self::Enum,
+            Self::ProtoType::Field => Self::Field,
+            Self::ProtoType::Function => Self::Function,
+            Self::ProtoType::Interface => Self::Interface,
+            Self::ProtoType::Keyword => Self::Keyword,
+            Self::ProtoType::Method => Self::Method,
+            Self::ProtoType::Module => Self::Module,
+            Self::ProtoType::Property => Self::Property,
+            Self::ProtoType::Reference => Self::Reference,
+            Self::ProtoType::Snippet => Self::Snippet,
+            Self::ProtoType::Text => Self::Text,
+            Self::ProtoType::Unit => Self::Unit,
+            Self::ProtoType::Value => Self::Value,
+            Self::ProtoType::Variable => Self::Variable,
         }
     }
 }
@@ -575,10 +562,10 @@ impl ProtoConversion for dap_types::Thread {
     type ProtoType = proto::DapThread;
     type Output = Self;
 
-    fn to_proto(&self) -> Self::ProtoType {
+    fn to_proto(self) -> Self::ProtoType {
         proto::DapThread {
             id: self.id,
-            name: self.name.clone(),
+            name: self.name,
         }
     }