並び順

ブックマーク数

期間指定

  • から
  • まで

1 - 4 件 / 4件

新着順 人気順

unwrapの検索結果1 - 4 件 / 4件

タグ検索の該当結果が少ないため、タイトル検索結果を表示しています。

unwrapに関するエントリは4件あります。 プログラミングtechfeedRust などが関連タグです。 人気エントリには 『Using unwrap() in Rust is Okay - Andrew Gallant's Blog』などがあります。
  • Using unwrap() in Rust is Okay - Andrew Gallant's Blog

    One day before Rust 1.0 was released, I published a blog post covering the fundamentals of error handling. A particularly important but small section buried in the middle of the article is named “unwrapping isn’t evil”. That section briefly described that, broadly speaking, using unwrap() is okay if it’s in test/example code or when panicking indicates a bug. I generally still hold that belief tod

    • Go の自作エラーを errors.Is と errors.As で wrap 元のエラーと識別するときには、Unwrap も実装しよう

      概要 Go ではデフォルトのエラーに対して、自作エラーを作成して wrap するように有識者の間では推奨されています。 ただ、wrap すると本来のエラーが隠れてしまいテストや実行時に単純な比較ができなくなります。 そこで、よく紹介されるのが、errors.Isとerrors.Asです。 erros.Isとerrors.Asを使うと wrap 済みエラーに対して、元のエラーとの比較できます。 しかし、紹介記事では、そのままコピー&ペーストするとtrueを返してほしいときに、falseを返してしまう方法を散見します。 本記事では、間違えてしまうパターンについて紹介し、解決方法を紹介します。 元のエラーが不要で、wrap したエラーのみで比較する実装のときには、本記事の手順は不要になります。 うまく比較できないパターン 最初に、うまく比較できないパターンがどのようなときに発生するのか紹介します

        Go の自作エラーを errors.Is と errors.As で wrap 元のエラーと識別するときには、Unwrap も実装しよう
      • Why Rust should only have provided `expect` for turning errors into panics, and not also provided `unwrap`

        UPDATE 2: I have made the title longer because people seem to be insisting on misunderstanding me, giving examples where the only reasonable thing to do is to escalate an Err into a panic. Indeed, such situations exist. I am not advocating for panic-free code. I am advocating that expect should be used for those functions, and if a function is particularly prone to being called like that (e.g. Mut

        • 生のjavascriptで親要素は削除するけど子要素は残す(jQueryのunwrapっぽく) - Qiita

          あるdivがあって、子要素は残しつつそのdivだけを削除したいというとき、生のjavascriptでどうやるのか意外と情報が見当たらなかったのでメモします。 jQueryのunwrap と同じことを生のjavascriptでやろうという目的です。 準備 前提としてこういうHTMLがあるとして、ボタンをクリックすると div タグは消すけど p タグは残すという処理を、 jQuery の場合と生の javascript の場合とで実装してみます。 <!-- jQueryの実験用 --> <button id="button1">ボタン</button> <div id="parent1"> <p>child</p> </div> <!-- 生のjavascriptの実験用 --> <button id="button2">ボタン</button> <div id="parent2"> <p>

            生のjavascriptで親要素は削除するけど子要素は残す(jQueryのunwrapっぽく) - Qiita
          1

          新着記事