<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/rust/kernel/static_assert.rs, branch v6.12.49</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v6.12.49</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v6.12.49'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2022-12-04T00:59:16Z</updated>
<entry>
<title>rust: static_assert: add `static_assert!` macro</title>
<updated>2022-12-04T00:59:16Z</updated>
<author>
<name>Miguel Ojeda</name>
<email>ojeda@kernel.org</email>
</author>
<published>2022-11-10T16:41:36Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=ef9e37973c3a50497c943e70d577dad10a8e41f2'/>
<id>urn:sha1:ef9e37973c3a50497c943e70d577dad10a8e41f2</id>
<content type='text'>
Add the `static_assert!` macro, which is a compile-time assert, similar
to the C11 `_Static_assert` and C++11 `static_assert` declarations [1,2].
Do so in a new module, called `static_assert`.

For instance:

    static_assert!(42 &gt; 24);
    static_assert!(core::mem::size_of::&lt;u8&gt;() == 1);

    const X: &amp;[u8] = b"bar";
    static_assert!(X[1] == b'a');

    const fn f(x: i32) -&gt; i32 {
        x + 2
    }
    static_assert!(f(40) == 42);

Link: https://en.cppreference.com/w/c/language/_Static_assert [1]
Link: https://en.cppreference.com/w/cpp/language/static_assert [2]
Co-developed-by: Alex Gaynor &lt;alex.gaynor@gmail.com&gt;
Signed-off-by: Alex Gaynor &lt;alex.gaynor@gmail.com&gt;
Signed-off-by: Miguel Ojeda &lt;ojeda@kernel.org&gt;
</content>
</entry>
</feed>
