1use crate::{std_types::RStr, type_layout::MonoTypeLayout};
23/// Represents the layout of a prefix-type,for use in error messages.
4#[repr(C)]
5#[derive(Debug, Copy, Clone, StableAbi)]
6// #[derive(Debug, Copy, Clone, PartialEq, StableAbi)]
7pub struct PTStructLayout {
8/// The stringified generic parameters.
9pub generics: RStr<'static>,
10/// The layout information of the type which doesn't depend on generic parameters
11pub mono_layout: &'static MonoTypeLayout,
12}
1314//////////////////////////////////////////////////////////////
1516impl PTStructLayout {
17/// Constructs a `PTStructLayout`.
18pub const fn new(generics: RStr<'static>, mono_layout: &'static MonoTypeLayout) -> Self {
19Self {
20 generics,
21 mono_layout,
22 }
23 }
2425/// Gets an iterator over the names of the fields.
26#[inline]
27pub fn get_field_names(&self) -> impl Iterator<Item = &'static str> {
28self.mono_layout.field_names()
29 }
3031/// Gets a `Vec` with the names of the fields.
32#[inline]
33pub fn get_field_names_vec(&self) -> Vec<&'static str> {
34self.mono_layout.field_names().collect()
35 }
3637/// Gets the name of the `ith` field, returning `None` if there is no `ith` field.
38#[inline]
39pub fn get_field_name(&self, ith: usize) -> Option<&'static str> {
40self.mono_layout.get_field_name(ith)
41 }
42}