A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://doc.rust-lang.org/nightly/std/marker/trait.StructuralPartialEq.html below:

StructuralPartialEq in std::marker - Rust

Trait StructuralPartialEqSource
pub trait StructuralPartialEq { }
🔬This is a nightly-only experimental API. (structural_match #31434) Expand description

Required trait for constants used in pattern matches.

Constants are only allowed as patterns if (a) their type implements PartialEq, and (b) interpreting the value of the constant as a pattern is equivalent to calling PartialEq. This ensures that constants used as patterns cannot expose implementation details in an unexpected way or cause semver hazards.

This trait ensures point (b). Any type that derives PartialEq automatically implements this trait.

Implementing this trait (which is unstable) is a way for type authors to explicitly allow comparing const values of this type; that operation will recursively compare all fields (including private fields), even if that behavior differs from PartialEq. This can make it semver-breaking to add further private fields to a type.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4