Host introspection: Difference between revisions

Added Rust
m (→‎{{header|Perl 6}}: changed sense of new test, as per S03-buf/read-num.t)
(Added Rust)
Line 1,033:
 
Some other implementations of Ruby are different. With [[JRuby]], a Fixnum is always 64 bits, because it is a Java <code>long</code> [http://www.jruby.org/git?p=jruby.git;a=blob;f=src/org/jruby/RubyFixnum.java;h=ba8d076d58d28c30ecd8e378e6e2482486dba22d;hb=HEAD#l91 (1)]. JRuby uses the correct native byte order by calling java.nio.ByteOrder.nativeOrder() [http://www.jruby.org/git?p=jruby.git;a=blob;f=src/org/jruby/platform/Platform.java;h=d84b0b55b1aca381b2101297185d3b7f872c8cfd;hb=HEAD#l110 (2)].
 
=={{header|Rust}}==
<lang Rust>#[derive(Copy, Clone, Debug)]
enum Endianness {
Big, Little,
}
 
impl Endianness {
fn target() -> Self {
#[cfg(target_endian = "big")]
{
Endianness::Big
}
#[cfg(not(target_endian = "big"))]
{
Endianness::Little
}
}
}
 
fn main() {
println!("Word size: {} bytes", std::mem::size_of::<usize>());
println!("Endianness: {:?}", Endianness::target());
}</lang>
 
{{out}}
<pre>Word size: 8 bytes
Endianness: Little</pre>
 
=={{header|Scala}}==
Anonymous user