{"id":35927,"date":"2022-05-19T15:58:52","date_gmt":"2022-05-19T19:58:52","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=35927"},"modified":"2022-05-19T15:58:52","modified_gmt":"2022-05-19T19:58:52","slug":"indirect-struct-properties-in-swift","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2022\/05\/19\/indirect-struct-properties-in-swift\/","title":{"rendered":"Indirect Struct Properties in Swift"},"content":{"rendered":"<p><a href=\"https:\/\/twitter.com\/BigZaphod\/status\/1526760341677408262\">Sean Heber<\/a>:<\/p>\n<blockquote cite=\"https:\/\/twitter.com\/BigZaphod\/status\/1526760341677408262\">\n<p>Surprised that Swift has &ldquo;indirect&rdquo; for enum cases but not for structs. Seems like a weird omission.<\/p>\n<p>Here&rsquo;s a <a href=\"https:\/\/gist.github.com\/BigZaphod\/1e65a03219606fb1e81cd1445518683f\">property wrapper<\/a> that lets you use &ldquo;indirect&rdquo; properties in a struct for those times when you really want to because &ldquo;reasons.&rdquo;<\/p>\n<\/blockquote>\n<p>It uses an <code>enum<\/code> wrapper, which is <a href=\"https:\/\/twitter.com\/jckarter\/status\/1526949943692234759\">more efficient<\/a> than an object.<\/p>","protected":false},"excerpt":{"rendered":"<p>Sean Heber: Surprised that Swift has &ldquo;indirect&rdquo; for enum cases but not for structs. Seems like a weird omission. Here&rsquo;s a property wrapper that lets you use &ldquo;indirect&rdquo; properties in a struct for those times when you really want to because &ldquo;reasons.&rdquo; It uses an enum wrapper, which is more efficient than an object.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"","apple_news_api_id":"","apple_news_api_modified_at":"","apple_news_api_revision":"","apple_news_api_share_url":"","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[71,901],"class_list":["post-35927","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-programming","tag-swift-programming-language"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/35927","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=35927"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/35927\/revisions"}],"predecessor-version":[{"id":35928,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/35927\/revisions\/35928"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=35927"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=35927"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=35927"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}