/// Path to a struct that may appear as an output. #[derive(Debug, Clone)] #[non_exhaustive] pubenum ReturnableStructPath { Struct(StructPath),
OutStruct(OutStructPath),
}
/// Path to a struct that can only be used as an output. pubtype OutStructPath = StructPath<OutputOnly>;
/// Path to a struct that can be used in inputs and outputs. #[derive(Debug, Clone)] #[non_exhaustive] pubstruct StructPath<P: TyPosition = Everywhere> { pub lifetimes: Lifetimes, pub tcx_id: P::StructId,
}
/// Path to an opaque. /// /// There are three kinds of opaques that Diplomat uses, so this type has two /// generic arguments to differentiate between the three, while still showing /// that the three are all paths to opaques. The monomorphized versions that /// Diplomat uses are: /// /// 1. `OpaquePath<Optional, MaybeOwn>`: Opaques in return types, /// which can be optional and either owned or borrowed. /// 2. `OpaquePath<Optional, Borrow>`: Opaques in method parameters, which can /// be optional but must be borrowed, since most languages don't have a way to /// entirely give up ownership of a value. /// 3. `OpaquePath<NonOptional, Borrow>`: Opaques in the `&self` position, which /// cannot be optional and must be borrowed for the same reason as above. #[derive(Debug, Clone)] #[non_exhaustive] pubstruct OpaquePath<Opt, Owner> { pub lifetimes: Lifetimes, pub optional: Opt, pub owner: Owner, pub tcx_id: OpaqueId,
}
/// Path to an enum. #[derive(Debug, Clone)] #[non_exhaustive] pubstruct EnumPath { pub tcx_id: EnumId,
}
/// Determine whether a pointer to an opaque type is owned or borrowed. /// /// Since owned opaques cannot be used as inputs, this only appears in output types. #[derive(Copy, Clone, Debug)] #[allow(clippy::exhaustive_enums)] // only two answers to this question pubenum MaybeOwn {
Own,
Borrow(Borrow),
}
impl<P: TyPosition> StructPath<P> { /// Returns a new [`EnumPath`]. pub(super) fn new(lifetimes: Lifetimes, tcx_id: P::StructId) -> Self { Self { lifetimes, tcx_id }
}
} impl StructPath { /// Returns the [`StructDef`] that this path references. pubfn resolve<'tcx>(&self, tcx: &'tcx TypeContext) -> &'tcx StructDef {
tcx.resolve_struct(self.tcx_id)
}
}
impl OutStructPath { /// Returns the [`OutStructDef`] that this path references. pubfn resolve<'tcx>(&self, tcx: &'tcx TypeContext) -> &'tcx OutStructDef {
tcx.resolve_out_struct(self.tcx_id)
}
/// Get a map of lifetimes used on this path to lifetimes as named in the def site. See [`LinkedLifetimes`] /// for more information. pubfn link_lifetimes<'def, 'tcx>(
&'def self,
tcx: &'tcx TypeContext,
) -> LinkedLifetimes<'def, 'tcx> { let struc = self.resolve(tcx); let env = &struc.lifetimes;
LinkedLifetimes::new(env, None, &self.lifetimes)
}
}
/// Returns the [`OpaqueDef`] that this path references. pubfn resolve<'tcx>(&self, tcx: &'tcx TypeContext) -> &'tcx OpaqueDef {
tcx.resolve_opaque(self.tcx_id)
}
}
impl<Opt, Owner: OpaqueOwner> OpaquePath<Opt, Owner> { /// Get a map of lifetimes used on this path to lifetimes as named in the def site. See [`LinkedLifetimes`] /// for more information. pubfn link_lifetimes<'def, 'tcx>(
&'def self,
tcx: &'tcx TypeContext,
) -> LinkedLifetimes<'def, 'tcx> { let opaque = self.resolve(tcx); let env = &opaque.lifetimes;
LinkedLifetimes::new(env, self.owner.lifetime(), &self.lifetimes)
}
}
impl EnumPath { /// Returns a new [`EnumPath`]. pub(super) fn new(tcx_id: EnumId) -> Self { Self { tcx_id }
}
/// Returns the [`EnumDef`] that this path references. pubfn resolve<'tcx>(&self, tcx: &'tcx TypeContext) -> &'tcx EnumDef {
tcx.resolve_enum(self.tcx_id)
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-06-19)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.