Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ internals = []

[dependencies]
arbitrary = { version = "1", optional = true, default-features = false }
borsh = { version = "1.8", optional = true, default-features = false }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a new cargo feature as well?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional dependencies automatically create a feature with the same name as the dependency

bytes = { version = "1", optional = true, default-features = false }
serde_core = { version = "1.0.221", optional = true, default-features = false }
malloc_size_of = { version = "0.1.1", optional = true, default-features = false }
Expand Down
20 changes: 20 additions & 0 deletions src/borsh.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
use {
super::SmallVec,
borsh::{
BorshSerialize,
io::{
Result as Serial,
Write
}
}
};

impl<Type: BorshSerialize, const INLINE: usize> BorshSerialize for SmallVec<Type, INLINE> {
fn serialize<Writer: Write>(&self, writer: &mut Writer) -> Serial<()> {
self.len.0.serialize(writer)?;
for element in self {
element.serialize(writer)?;
}
return Ok(());
}
}
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ pub extern crate alloc;
#[cfg(any(test, feature = "std"))]
extern crate std;

#[cfg(feature = "borsh")]
mod borsh;
mod rawsmallvec;

#[cfg(feature = "bytes")]
Expand Down
Loading