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

Api to consume Extensions and import/export all items

未关闭
#780 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
rust

调研方向

先阅读 Extensions 和 AnyClone 类型,然后查看相关 issue #299 以及提议的 IntoIterator 示例。比较用于导出所有扩展项并将其导入新的或现有 Extensions 对象的各种 API。完成的标准是:项目拥有一个已达成共识且可用的互操作 API,而不是依赖嵌套 typemap 变通方案。

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

描述

When traversing boundaries it's currently quite hard (nearly impossible) to extract all extensions and transfer them to somewhere else. There are some creative ways to work around this, like inserting a nested typemap into extensions, but these are all quite hacky.

Would you be open into some sort of api that can consume extensions and return the individual items, and then later add these back to a new or existing Extension object?

A very quick solution could be something like

impl IntoIterator for Extensions {
    type Item = (TypeId, Box<dyn AnyClone + Send + Sync>);
    type IntoIter = std::vec::IntoIter<Self::Item>;

    fn into_iter(self) -> Self::IntoIter {
        match self.map {
            None => Default::default(),
            Some(map) => {
                map.into_iter().collect::<Vec<_>>().into_iter()
            }
        }
        
    }
}

But it could be anything else, only requirement would be the functionality to export all items from extensions and import them back again. The example implementation also hides away the usage of a hashmap so this detail could be changed in the future if needed. But it does require AnyClone to be public (can be sealed). Please don't focus on this solution too much as I haven't really given it much thought, it's just here as an example / starting point.

I'm really open to all suggestions here on how to support this or what other solutions there might be available. Having extensions be interoperable with other type maps would be really useful and would make extensions much more flexible.

This is slightly related to https://github.com/hyperium/http/issues/299

主要语言
Rust
星标
1.4k
派生
378
平均合并
1 天 21 小时
30 天内合并 PR
5

贡献指南

这个仓库没有索引到贡献指南

从这里开始

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

hyperium/http 的其他 Issue

查看 hyperium/http 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

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