Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–7 unchanged (7 lines)
8//! Traits that are implemented by codegen types.
9
10use crate::AsMut;
11use crate::AsView;
12use crate::IntoMut;
13use crate::IntoView;
14use crate::MutProxied;
15use crate::__internal::runtime::{KernelMessage, KernelMessageMut, KernelMessageView};
16use crate::__internal::SealedInternal;
17use create::Parse;
18use interop::{MessageMutInterop, MessageViewInterop, OwnedMessageInterop};
19use read::Serialize;
20use std::fmt::Debug;
…lines 21–84 unchanged (64 lines)
85 + MessageMutInterop<'msg>
86 + KernelMessageMut
87{
88 /// The owned message type that this is a mut of.
89 type Message: Message;
90}
91
92/// Operations related to constructing a message. Only owned messages implement
93/// these traits.
94pub(crate) mod create {
95 use super::SealedInternal;
96 pub trait Parse: SealedInternal + Sized {
97 fn parse(serialized: &[u8]) -> Result<Self, crate::ParseError>;
…lines 98–311 unchanged (214 lines)

After

…lines 1–9 unchanged (9 lines)
10use crate::AsMut;
11use crate::AsView;
12use crate::IntoMut;
13use crate::IntoView;
14use crate::__internal::runtime::{KernelMessage, KernelMessageMut, KernelMessageView};
15use crate::__internal::SealedInternal;
16use crate::{MutProxied, ProtoBytes, ProtoString};
17use create::Parse;
18use interop::{MessageMutInterop, MessageViewInterop, OwnedMessageInterop};
19use read::Serialize;
20use std::fmt::Debug;
21use write::{Clear, ClearAndParse, CopyFrom, MergeFrom, TakeFrom};
22
…lines 23–85 unchanged (63 lines)
86 + KernelMessageMut
87{
88 /// The owned message type that this is a mut of.
89 type Message: Message;
90}
91
92/// This trait allows us to associate a tag with each type of protobuf entity. The tag indicates
93/// whether the entity is a message, enum, primitive, view proxy, or mut proxy. The main purpose of
94/// this is to allow us to have separate blanket implementations of various traits for messages
95/// and enums.
96pub trait EntityType {
97 type Tag;
98}
99
100pub mod entity_tag {
101 pub struct MessageTag;
102 pub struct EnumTag;
103 pub struct PrimitiveTag;
104 pub struct ViewProxyTag;
105 pub struct MutProxyTag;
106}
107
108macro_rules! impl_entity_type_for_primitives {
109 ($($t:ty,)*) => {
110 $(
111 impl EntityType for $t {
112 type Tag = entity_tag::PrimitiveTag;
113 }
114 )*
115 };
116}
117
118impl_entity_type_for_primitives!(f32, f64, i32, u32, i64, u64, bool, ProtoBytes, ProtoString,);
119
120/// Operations related to constructing a message. Only owned messages implement
121/// these traits.
122pub(crate) mod create {
123 use super::SealedInternal;
124 pub trait Parse: SealedInternal + Sized {
…lines 125–339 unchanged (215 lines)

Before

source_file
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " Traits that are implemented by codegen types.\n"
use_declaration
use "use"
scoped_identifier
crate "crate"
:: "::"
identifier "AsMut"
; ";"
use_declaration
use "use"
scoped_identifier
crate "crate"
:: "::"
identifier "AsView"
; ";"
use_declaration
use "use"
scoped_identifier
crate "crate"
:: "::"
identifier "IntoMut"
; ";"
use_declaration
use "use"
scoped_identifier
crate "crate"
:: "::"
identifier "IntoView"
; ";"
use_declaration
use "use"
scoped_identifier
crate "crate"
:: "::"
identifier "MutProxied"
; ";"
use_declaration
use "use"
scoped_use_list
scoped_identifier
scoped_identifier
crate "crate"
:: "::"
identifier "__internal"
:: "::"
identifier "runtime"
:: "::"
use_list
{ "{"
identifier "KernelMessage"
, ","
identifier "KernelMessageMut"
, ","
identifier "KernelMessageView"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
scoped_identifier
crate "crate"
:: "::"
identifier "__internal"
:: "::"
identifier "SealedInternal"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "create"
:: "::"
identifier "Parse"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "interop"
:: "::"
use_list
{ "{"
identifier "MessageMutInterop"
, ","
identifier "MessageViewInterop"
, ","
identifier "OwnedMessageInterop"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "read"
:: "::"
identifier "Serialize"
; ";"
use_declaration
use "use"
scoped_identifier
scoped_identifier
identifier "std"
:: "::"
identifier "fmt"
:: "::"
identifier "Debug"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "write"
:: "::"
use_list
{ "{"
identifier "Clear"
, ","
identifier "ClearAndParse"
, ","
identifier "CopyFrom"
, ","
identifier "MergeFrom"
, ","
identifier "TakeFrom"
} "}"
; ";"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " A trait that all generated owned message types implement.\n"
trait_item (+191 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " A trait that all generated message views implement.\n"
trait_item (+93 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " A trait that all generated message muts implement.\n"
trait_item (+131 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Operations related to constructing a message. Only owned me"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " these traits.\n"
mod_item (+261 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Operations related to reading some aspect of a message (met"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " have a `&self` receiver on an owned message). Owned message"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " muts all implement these traits.\n"
mod_item (+56 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Operations related to mutating a message (methods that woul"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " self` receiver on an owned message). Owned messages and mut"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " traits.\n"
mod_item (+305 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Traits related to interop with C or C++.\n"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment "\n"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " These traits are deliberately not available on the prelude,"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " be used rarely and with great care.\n"
mod_item (+822 nodes collapsed)

After

source_file
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " Traits that are implemented by codegen types.\n"
use_declaration
use "use"
scoped_identifier
crate "crate"
:: "::"
identifier "AsMut"
; ";"
use_declaration
use "use"
scoped_identifier
crate "crate"
:: "::"
identifier "AsView"
; ";"
use_declaration
use "use"
scoped_identifier
crate "crate"
:: "::"
identifier "IntoMut"
; ";"
use_declaration
use "use"
scoped_identifier
crate "crate"
:: "::"
identifier "IntoView"
; ";"
use_declaration
use "use"
scoped_use_list
scoped_identifier
scoped_identifier
crate "crate"
:: "::"
identifier "__internal"
:: "::"
identifier "runtime"
:: "::"
use_list
{ "{"
identifier "KernelMessage"
, ","
identifier "KernelMessageMut"
, ","
identifier "KernelMessageView"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
scoped_identifier
crate "crate"
:: "::"
identifier "__internal"
:: "::"
identifier "SealedInternal"
; ";"
use_declaration
use "use"
scoped_use_list
crate "crate"
:: "::"
use_list
{ "{"
identifier "MutProxied"
, ","
identifier "ProtoBytes"
, ","
identifier "ProtoString"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "create"
:: "::"
identifier "Parse"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "interop"
:: "::"
use_list
{ "{"
identifier "MessageMutInterop"
, ","
identifier "MessageViewInterop"
, ","
identifier "OwnedMessageInterop"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "read"
:: "::"
identifier "Serialize"
; ";"
use_declaration
use "use"
scoped_identifier
scoped_identifier
identifier "std"
:: "::"
identifier "fmt"
:: "::"
identifier "Debug"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "write"
:: "::"
use_list
{ "{"
identifier "Clear"
, ","
identifier "ClearAndParse"
, ","
identifier "CopyFrom"
, ","
identifier "MergeFrom"
, ","
identifier "TakeFrom"
} "}"
; ";"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " A trait that all generated owned message types implement.\n"
trait_item (+191 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " A trait that all generated message views implement.\n"
trait_item (+93 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " A trait that all generated message muts implement.\n"
trait_item (+131 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " This trait allows us to associate a tag with each type of p"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " whether the entity is a message, enum, primitive, view prox"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " this is to allow us to have separate blanket implementation"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " and enums.\n"
trait_item
visibility_modifier
pub "pub"
trait "trait"
type_identifier "EntityType"
declaration_list
{ "{"
associated_type
type "type"
type_identifier "Tag"
; ";"
} "}"
mod_item
visibility_modifier
pub "pub"
mod "mod"
identifier "entity_tag"
declaration_list
{ "{"
struct_item
visibility_modifier
pub "pub"
struct "struct"
type_identifier "MessageTag"
; ";"
struct_item
visibility_modifier
pub "pub"
struct "struct"
type_identifier "EnumTag"
; ";"
struct_item
visibility_modifier
pub "pub"
struct "struct"
type_identifier "PrimitiveTag"
; ";"
struct_item
visibility_modifier
pub "pub"
struct "struct"
type_identifier "ViewProxyTag"
; ";"
struct_item
visibility_modifier
pub "pub"
struct "struct"
type_identifier "MutProxyTag"
; ";"
} "}"
macro_definition
macro_rules! "macro_rules!"
identifier "impl_entity_type_for_primitives"
{ "{"
macro_rule
token_tree_pattern
( "("
token_repetition_pattern
$ "$"
( "("
token_binding_pattern
metavariable "$t"
: ":"
fragment_specifier
ty "ty"
, ","
) ")"
* "*"
) ")"
=> "=>"
token_tree
{ "{"
token_repetition
$ "$"
( "("
impl "impl"
identifier "EntityType"
for "for"
metavariable "$t"
token_tree
{ "{"
type "type"
identifier "Tag"
= "="
identifier "entity_tag"
:: "::"
identifier "PrimitiveTag"
; ";"
} "}"
) ")"
* "*"
} "}"
; ";"
} "}"
expression_statement
macro_invocation
identifier "impl_entity_type_for_primitives"
! "!"
token_tree
( "("
primitive_type "f32"
, ","
primitive_type "f64"
, ","
primitive_type "i32"
, ","
primitive_type "u32"
, ","
primitive_type "i64"
, ","
primitive_type "u64"
, ","
primitive_type "bool"
, ","
identifier "ProtoBytes"
, ","
identifier "ProtoString"
, ","
) ")"
; ";"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Operations related to constructing a message. Only owned me"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " these traits.\n"
mod_item (+261 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Operations related to reading some aspect of a message (met"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " have a `&self` receiver on an owned message). Owned message"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " muts all implement these traits.\n"
mod_item (+56 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Operations related to mutating a message (methods that woul"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " self` receiver on an owned message). Owned messages and mut"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " traits.\n"
mod_item (+305 nodes collapsed)
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " Traits related to interop with C or C++.\n"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment "\n"
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " These traits are deliberately not available on the prelude,"...
line_comment
// "//"
outer_doc_comment_marker
/ "/"
doc_comment " be used rarely and with great care.\n"
mod_item (+822 nodes collapsed)