惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
有赞技术团队
有赞技术团队
IT之家
IT之家
博客园 - 聂微东
Jina AI
Jina AI
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
小众软件
小众软件
爱范儿
爱范儿
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
阮一峰的网络日志
阮一峰的网络日志
宝玉的分享
宝玉的分享
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
博客园 - Franky
量子位
月光博客
月光博客
博客园 - 【当耐特】
博客园 - 叶小钗

The Rust Programming Language Forum - Latest posts

What's everyone working on this week (21/2026)? Rust Function Call with one Param Iced + Canvas + Text: How do I create a style for canvas text "Value dropped while borrowed" as a lifetime mismatch Weird `use of moved value` behaviour Slightly surprising behavior of a while loop Clap: how to disable options after a certain positional argument How do i tell rust-analyzer what kind of bracket to use for a macro? Iterator + Borrow Checker: Work around borrowing already borrowed mutable variable Requesting data via mavlink SKILLS.md for Rust development 🧵 Stringlet UTF-8 Hack Option Niche? Iterator + Map - How do divide every element, including the last element, by the last element Why can't we store returned value of a function in a variable if one of the parameters goes out of scope My first crate :D, floop: A more convenient and less error prone replacement for loop `{ select! { .. }}` Sorting is slow because architectures are wrong — zan-sort redesigns the architecture, not the algorithm Iced Font - Create a custom monospace font to display dollar amounts Is the UnsafePinned RFC wrong about being able to return `&mut T` from `get_mut_unchecked`? Fixing Polars 0.37 compilation errors: Hashbrown 0.17 dependency conflict and decimal parsing Any plans for improving error diagnostic in Rust 2.0? How do I build completely offline? Is `&mut T -> &mut ManuallyDrop<T>` well-defined and sound? Would you use this? — fixtura, declarative fake data injection for tests Foreign trait restrictions on native types make generics hard to use Cargo Exclude Directive Compiler reasoning around a modulo counter Multiple mutable references to elements within one vector Handling non-`Send` data in a `Send` closure Review: Static Multi Pool Allocator Rmquickjs - High-level MicroQuickJS bindings for Rust
Borsh v1.6.1 example
Jit-coder-58 · 2026-04-20 · via The Rust Programming Language Forum - Latest posts

Here is the link for borsh v1.6.1 page (crates.io: Rust Package Registry). I tried to use the code example posted in the page and got several compilation errors. I added dependency in rust Cargo.toml file, as suggested, and the code:
[dependencies]
borsh = "1.6.1"
borsh-derive = "1.6.1"

#[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug)]
struct A {
    x: u64,
    y: String,
}

fn main() {
    let a = A {
        x: 3301,
        y: "liber primus".to_string(),
    };
    let encoded_a = to_vec(&a).unwrap();
    println!("Encoded serialization : {encoded_a:?}");
    let decoded_a = from_slice::<A>(&encoded_a).unwrap();
    println!("Decoded serialization: {decoded_a:?}");
    assert_eq!(a, decoded_a);
}

Some of the errors are posted below:
cannot find derive macro BorshSerialize in this scope
--> src\main.rs:3:10
|
3 | #[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug)]
| ^^^^^^^^^^^^^^
|
note: BorshSerialize is imported here, but it is only a trait, without a derive macro
--> src\main.rs:1:13
|
1 | use borsh::{BorshSerialize, BorshDeserialize, from_slice, to_vec};
| ^^^^^^^^^^^^^^

error: cannot find derive macro BorshDeserialize in this scope
--> src\main.rs:3:26
|
3 | #[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug)]
| ^^^^^^^^^^^^^^^^
|
note: BorshDeserialize is imported here, but it is only a trait, without a derive macro
--> src\main.rs:1:29
|
1 | use borsh::{BorshSerialize, BorshDeserialize, from_slice, to_vec};
| ^^^^^^^^^^^^^^^^

error[E0277]: the trait bound A: BorshSerialize is not satisfied
--> src\main.rs:14:28
|
14 | let encoded_a = to_vec(&a).unwrap();
| ------ ^^ unsatisfied trait bound
| |
| required by a bound introduced by this call
|
help: the trait BorshSerialize is not implemented for A
--> src\main.rs:4:1 and so on...

However, If I specifically import borsh_derive (se borsh_derive::{BorshSerialize, BorshDeserialize}:wink: and add vector type (let encoded_a: Vec = to_vec(&a).unwrap(), the errors go awasy and the code is compiled.