Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Reserver does not need to be generic

未关闭 适合新手
#195 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
backend

调研方向

从 issue 中引用的 Reserver 结构体及其 Debug 和固有 impl 代码块开始,然后找到 Reserver<ChunkId, ChunkId> 被构造和使用的位置。移除类型参数,使字段 reservations 和 pending_removals 直接使用 ChunkId,并相应更新 impl 代码块和调用位置。当 crate 能通过 cargo check 编译,且现有测试能通过 cargo test 时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

The Reserver<K,V> currently has two type parameters, but is only ever created as Reserver<ChunkId, ChunkId>. Removing the type parameters and making the Reserver non-generic will make it more simple.

The current generic code:

pub struct Reserver<K, V> {
    reservations: Cache<K, (V, UnboundedSender<V>, Instant), FxBuildHasher>,
    pending_removals: Arc<Mutex<DelayQueue<K>>>,
}

impl<K, V> core::fmt::Debug for Reserver<K, V>
where
    K: Hash + Eq + Send + Sync + Debug + Copy + 'static,
    V: Send + Sync + Clone + Debug + 'static,
{
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.debug_struct("Reserver")
            .field("reservations", &self.reservations)
            .field("&pending_removals", &self.pending_removals)
            .finish()
    }
}

impl<K, V> Reserver<K, V>
where
    K: Hash + Eq + Send + Sync + Debug + Copy + 'static,
    V: Send + Sync + Clone + 'static,
主要语言
Rust
星标
96
派生
2
平均合并
8 天 22 小时
30 天内合并 PR
2

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

channable/opsqueue 的其他 Issue

查看 channable/opsqueue 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。