Skip to content

Commit abfb8a3

Browse files
author
dj8yf0μl
committed
chore: add comments
1 parent 6f0ae64 commit abfb8a3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

borsh/examples/serde_json_value.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ mod serde_json_value {
7070

7171
/// this is mutually recursive with `serialize_value`
7272
fn serialize_array<W: Write>(array: &Vec<serde_json::Value>, writer: &mut W) -> Result<()> {
73+
// The implementation here is very similar to that of Vec<V>.
7374
writer.write_all(
7475
&(u32::try_from(array.len()).map_err(|_| ErrorKind::InvalidData)?).to_le_bytes(),
7576
)?;
@@ -84,7 +85,7 @@ mod serde_json_value {
8485
map: &serde_json::Map<String, serde_json::Value>,
8586
writer: &mut W,
8687
) -> Result<()> {
87-
// The implementation here is identical to that of BTreeMap<String, serde_json::Value>.
88+
// The implementation here is very similar to that of BTreeMap<K, V>.
8889
u32::try_from(map.len())
8990
.map_err(|_| ErrorKind::InvalidData)?
9091
.serialize(writer)?;
@@ -179,6 +180,7 @@ mod serde_json_value {
179180

180181
/// this is mutually recursive with `deserialize_value`
181182
fn deserialize_array<R: Read>(reader: &mut R) -> Result<Vec<serde_json::Value>> {
183+
// The implementation here is very similar to that of Vec<V>.
182184
let len = u32::deserialize_reader(reader)?;
183185
let mut result = Vec::with_capacity(hint_cautious::<(String, serde_json::Value)>(len));
184186
for _ in 0..len {
@@ -192,9 +194,10 @@ mod serde_json_value {
192194
fn deserialize_map<R: Read>(
193195
reader: &mut R,
194196
) -> Result<serde_json::Map<String, serde_json::Value>> {
195-
// The implementation here is identical to that of BTreeMap<String, serde_json::Value>.
197+
// The implementation here is very similar to that of BTreeMap<K, V>.
196198

197199
let vec: Vec<(String, serde_json::Value)> = {
200+
// The implementation here is very similar to that of Vec<(K, V)>.
198201
let len = u32::deserialize_reader(reader)?;
199202
let mut result =
200203
Vec::with_capacity(hint_cautious::<(String, serde_json::Value)>(len));

0 commit comments

Comments
 (0)