What type is [u16]?

⚓ Rust    📅 2026-01-06    👤 surdeus    👁️ 2      

surdeus

Info

This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: What type is [u16]?

In tiff crate, to encode tags and their values, there's this trait tiff::encoder::TiffValue. In foreign type implementations, there's a list of [T] types. But what are they? These aren't sized arrays, nor vectors.

I create tiff encoder, then I access the DirectoryEncoder, that encodes tags, then I try writing a tag with write_tag method:

let te = TiffEncoder::something...
let directory = te.image_directory()?;
let geokey: Vec<u16> = vec![1, 1, 0, 7, 1024, 0, 1, 1, 1025, 0, 1, 1, 1026, 34737, 25, 0, 2049, 34737, 7, 25, 2054, 0, 1, 9102, 3072, 0, 1, 3857, 3076, 0, 1, 9001];
directory.write_tag(Tag::GeoKeyDirectoryTag, &geokey);
                                             ^^^^^^^

The error is that my geokey does not implement TiffValue trait. I tried both vector, Vec<i16>, and array, in this case it's [u16; 32]. I also tried passing each of these by reference. Nothing works.

So, what is [u16] type?

4 posts - 3 participants

Read full topic

🏷️ Rust_feed