Skip to content

Commit 4378b50

Browse files
authored
adapter/docs: Add TODO doc for the AsAny trait (#30979)
@frankmcsherry I was reminded of this while we were chatting about box clone. ### Motivation Fix TODO ### Checklist - [ ] This PR has adequate test coverage / QA involvement has been duly considered. ([trigger-ci for additional test/nightly runs](https://trigger-ci.dev.materialize.com/)) - [ ] This PR has an associated up-to-date [design doc](https://github.com/MaterializeInc/materialize/blob/main/doc/developer/design/README.md), is a design doc ([template](https://github.com/MaterializeInc/materialize/blob/main/doc/developer/design/00000000_template.md)), or is sufficiently small to not require a design. <!-- Reference the design in the description. --> - [ ] If this PR evolves [an existing `$T ⇔ Proto$T` mapping](https://github.com/MaterializeInc/materialize/blob/main/doc/developer/command-and-response-binary-encoding.md) (possibly in a backwards-incompatible way), then it is tagged with a `T-proto` label. - [ ] If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label ([example](https://github.com/MaterializeInc/cloud/pull/5021)). <!-- Ask in #team-cloud on Slack if you need help preparing the cloud PR. --> - [ ] If this PR includes major [user-facing behavior changes](https://github.com/MaterializeInc/materialize/blob/main/doc/developer/guide-changes.md#what-changes-require-a-release-note), I have pinged the relevant PM to schedule a changelog post.
1 parent 69c3786 commit 4378b50

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/sql/src/session/vars/value.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,14 @@ impl<'a> PartialEq for &'a dyn Value {
7575
}
7676
impl<'a> Eq for &'a dyn Value {}
7777

78-
/// Helper trait ...
78+
/// Helper trait to cast a `&dyn T` to a `&dyn Any`.
7979
///
80-
/// TODO(parkmycar): Document why this exists
80+
/// In Rust all types that are `'static` implement [`std::any::Any`] and thus can be casted to a
81+
/// `&dyn Any`. But once you create a trait object, the type is erased and thus so is the
82+
/// implementation for [`Any`]. This trait essentially adds a types' [`Any`] impl to the vtable
83+
/// created when casted to trait object, if [`AsAny`] is a supertrait.
84+
///
85+
/// See [`Value`] for an example of using [`AsAny`].
8186
pub trait AsAny {
8287
fn as_any(&self) -> &dyn Any;
8388
}

0 commit comments

Comments
 (0)