Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`slice-dst`: Provide example for custom 'slices' using `SliceWithHeader`

オープン
#69 コメント 7 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
ドキュメント
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
rust
領域
documentation

調査の方向性

issue の SliceWithHeader 型とカスタム MyString/MyStr の例から始めます。ファイルやテストは特定されていません。提案されている参照変換の安全性要件を確立し、その後、カスタム slice の完全な例と、期待される Borrow/ToOwned の動作を文書化します。

索引モデルが issue の本文から書いたものです。

説明

documentation good first issue

Thank you for this awesome crate. I always respect when people dive into the unsafe world of Rust.

I'd like to use the slice-dst crate to build something similar to String and str. Let's assume:

struct MyString(Box<SliceWithHeader<Info, u8>>);

To mimicry str I want to implement Borrow<MyStr> for MyString and ToOwned for MyStr (type Owned = MyString). However, I have a problem defining MyStr. I could use a type alias:

type MyStr = SliceWithHeader<Info, u8>;

But this is inconvenient and won't allow some custom impl MyStr. What I would like is to use is a new-type-pattern. But this makes it difficult implementing Borrow:

struct MyStr(SliceWithHeader<Info, u8>);

impl Borrow<MyStr> for MyString {
    fn borrow(&self) -> &MyStr {
        &*self.0 // <-- requires some cast/convertion/idk
    }
}

Would it be safe to simple cast the reference from the Box within MyString to a &MyStr or would this be undefined behavior?

主要言語
Rust
スター
137
フォーク
15
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

CAD97/pointer-utils のほかの issue

CAD97/pointer-utils の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。