{"version":"1.0","type":"rich","published":"2020-08-24 18:30:00","author_name":"USAGI-WRP","author_url":"https://blog.hatena.ne.jp/USAGI-WRP/","height":"190","provider_name":"Hatena Blog","blog_title":"C++ \u3068\u304d\u3069\u304d \u3054\u306f\u3093\u3001\u308f\u308a\u3068\u3066\u3043\u30fc\u3076\u308c\u3044\u304f\u2606","categories":["Rust","trait","Option","Result","E0277","workaround"],"image_url":null,"blog_url":"https://usagi.hatenablog.jp/","width":"100%","url":"https://usagi.hatenablog.jp/entry/2020/08/24/183000","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fusagi.hatenablog.jp%2Fentry%2F2020%2F08%2F24%2F183000\" title=\"Rust \u306e trait \u3067 Option&lt;Self&gt; \u3084 Result&lt;Self, E&gt; \u3092 return \u3059\u308b\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u3088\u3046\u3068\u3057\u3066 [E0277] \u3067\u6012\u3089\u308c\u305f\u6642\u306b\u601d\u3044\u51fa\u3059\u30e1\u30e2 - C++ \u3068\u304d\u3069\u304d \u3054\u306f\u3093\u3001\u308f\u308a\u3068\u3066\u3043\u30fc\u3076\u308c\u3044\u304f\u2606\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","description":"\u554f\u984c // \u2193\u3053\u308c\u306f\u554f\u984c\u3042\u308a\u307e\u305b\u3093 trait Trait { fn function() -> Self; } // \u2193\u3053\u308c\u306f E0277: the size for values of type `Self` cannot be known at compilation time trait TraitOptional { fn function() -> Option<Self>; } // -> Result<Self, E> \u3068\u304b\u3059\u308b\u5834\u5408\u3082\u540c\u69d8\u3067\u3059(\u7701\u7565) \u56de\u907f\u65b9\u6cd5 // Self \u306e\u4ee3\u308f\u308a\u306b\u30b8\u30a7\u30cd\u30ea\u30af\u30b9\u3092\u565b\u307e\u305b\u3066 trait TraitOptional<T> { fn functi\u2026","provider_url":"https://hatena.blog","title":"Rust \u306e trait \u3067 Option<Self> \u3084 Result<Self, E> \u3092 return \u3059\u308b\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u3088\u3046\u3068\u3057\u3066 [E0277] \u3067\u6012\u3089\u308c\u305f\u6642\u306b\u601d\u3044\u51fa\u3059\u30e1\u30e2"}