tamer: asg::graph::Asg::try_map_obj: Make private
Only internal modules ought to be able to mutate objects. This is important now with the use of the `f::Map` trait, since traits don't allow for private methods, which were previously the means of maintaining encapsulation. DEV-13163main
parent
7001b50543
commit
6c2bfa936a
|
@ -287,6 +287,14 @@ impl Asg {
|
|||
/// see the [`object` module documentation](object) for more
|
||||
/// information and rationale on this behavior.
|
||||
///
|
||||
/// This method is intentionally private:
|
||||
/// while it is possible for external systems to receive immutable
|
||||
/// references to objects,
|
||||
/// mutation of those objects is intended to remain encapsulated.
|
||||
/// This is especially important given the use of the [`Map`] trait by
|
||||
/// objects,
|
||||
/// since traits yield public APIs.
|
||||
///
|
||||
/// Panics
|
||||
/// ======
|
||||
/// This method chooses to simplify the API by choosing panics for
|
||||
|
@ -302,7 +310,7 @@ impl Asg {
|
|||
/// representing a type mismatch between what the caller thinks
|
||||
/// this object represents and what the object actually is.
|
||||
#[must_use = "returned ObjectIndex has a possibly-updated and more relevant span"]
|
||||
pub(super) fn try_map_obj<O: ObjectKind, E>(
|
||||
fn try_map_obj<O: ObjectKind, E>(
|
||||
&mut self,
|
||||
index: ObjectIndex<O>,
|
||||
f: impl FnOnce(O) -> Result<O, (O, E)>,
|
||||
|
|
|
@ -758,7 +758,7 @@ impl<O: ObjectKind> ObjectIndex<O> {
|
|||
///
|
||||
/// If this operation is [`Infallible`],
|
||||
/// see [`Self::map_obj`].
|
||||
pub fn try_map_obj<E>(
|
||||
fn try_map_obj<E>(
|
||||
self,
|
||||
asg: &mut Asg,
|
||||
f: impl FnOnce(O) -> Result<O, (O, E)>,
|
||||
|
@ -775,7 +775,7 @@ impl<O: ObjectKind> ObjectIndex<O> {
|
|||
///
|
||||
/// If this operation is [`Infallible`],
|
||||
/// see [`Self::map_obj_inner`].
|
||||
pub fn try_map_obj_inner<T, E>(
|
||||
fn try_map_obj_inner<T, E>(
|
||||
self,
|
||||
asg: &mut Asg,
|
||||
f: impl FnOnce(T) -> <O as TryMap<T>>::FnResult<E>,
|
||||
|
@ -792,7 +792,7 @@ impl<O: ObjectKind> ObjectIndex<O> {
|
|||
///
|
||||
/// If this operation is _not_ [`Infallible`],
|
||||
/// see [`Self::try_map_obj`].
|
||||
pub fn map_obj(self, asg: &mut Asg, f: impl FnOnce(O) -> O) -> Self {
|
||||
fn map_obj(self, asg: &mut Asg, f: impl FnOnce(O) -> O) -> Self {
|
||||
// This verbose notation (in place of e.g. `unwrap`) is intentional
|
||||
// to emphasize why it's unreachable and to verify our assumptions
|
||||
// at every point.
|
||||
|
@ -811,7 +811,7 @@ impl<O: ObjectKind> ObjectIndex<O> {
|
|||
///
|
||||
/// If this operation is _not_ [`Infallible`],
|
||||
/// see [`Self::try_map_obj_inner`].
|
||||
pub fn map_obj_inner<T>(self, asg: &mut Asg, f: impl FnOnce(T) -> T) -> Self
|
||||
fn map_obj_inner<T>(self, asg: &mut Asg, f: impl FnOnce(T) -> T) -> Self
|
||||
where
|
||||
O: Map<T, Target = O>,
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue