fixed_bigint/fixeduint/has_personality_impl.rs
1// Copyright 2021 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! `HasPersonality` projection for FixedUInt: the carrier's declared
16//! personality is its type parameter, so downstream personality gates
17//! (`T: HasPersonality<P = Nct>`) resolve without naming FixedUInt.
18
19use super::{FixedUInt, MachineWord};
20use const_num_traits::{HasPersonality, Personality};
21
22impl<T: MachineWord, const N: usize, P: Personality> HasPersonality for FixedUInt<T, N, P> {
23 type P = P;
24}
25
26#[cfg(test)]
27mod tests {
28 use const_num_traits::{Ct, HasPersonality, Nct};
29
30 type U64 = crate::FixedUInt<u32, 2>;
31 type U64Ct = crate::FixedUInt<u32, 2, Ct>;
32
33 #[test]
34 fn projects_declared_personality() {
35 fn assert_nct<T: HasPersonality<P = Nct>>() {}
36 fn assert_ct<T: HasPersonality<P = Ct>>() {}
37 assert_nct::<U64>();
38 assert_ct::<U64Ct>();
39 }
40}