+++ /dev/null
-# `associated_consts`
-
-The tracking issue for this feature is: [#29646]
-
-[#29646]: https://github.com/rust-lang/rust/issues/29646
-
-------------------------
-
-With the `associated_consts` feature, you can define constants like this:
-
-```rust
-#![feature(associated_consts)]
-
-trait Foo {
- const ID: i32;
-}
-
-impl Foo for i32 {
- const ID: i32 = 1;
-}
-
-fn main() {
- assert_eq!(1, i32::ID);
-}
-```
-
-Any implementor of `Foo` will have to define `ID`. Without the definition:
-
-```rust,ignore
-#![feature(associated_consts)]
-
-trait Foo {
- const ID: i32;
-}
-
-impl Foo for i32 {
-}
-```
-
-gives
-
-```text
-error: not all trait items implemented, missing: `ID` [E0046]
- impl Foo for i32 {
- }
-```
-
-A default value can be implemented as well:
-
-```rust
-#![feature(associated_consts)]
-
-trait Foo {
- const ID: i32 = 1;
-}
-
-impl Foo for i32 {
-}
-
-impl Foo for i64 {
- const ID: i32 = 5;
-}
-
-fn main() {
- assert_eq!(1, i32::ID);
- assert_eq!(5, i64::ID);
-}
-```
-
-As you can see, when implementing `Foo`, you can leave it unimplemented, as
-with `i32`. It will then use the default value. But, as in `i64`, we can also
-add our own definition.
-
-Associated constants don’t have to be associated with a trait. An `impl` block
-for a `struct` or an `enum` works fine too:
-
-```rust
-#![feature(associated_consts)]
-
-struct Foo;
-
-impl Foo {
- const FOO: u32 = 3;
-}
-```
#![feature(allow_internal_unstable)]
#![feature(asm)]
#![feature(associated_type_defaults)]
-#![feature(associated_consts)]
#![feature(cfg_target_feature)]
#![feature(cfg_target_has_atomic)]
#![feature(concat_idents)]
#![feature(untagged_unions)]
#![feature(unwind_attributes)]
+#![cfg_attr(stage0, feature(associated_consts))]
+
#[prelude_import]
#[allow(unused)]
use prelude::v1::*;
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]
-#![feature(associated_consts)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(conservative_impl_trait)]
#![feature(trace_macros)]
#![feature(test)]
+#![cfg_attr(stage0, feature(associated_consts))]
+
#![recursion_limit="256"]
extern crate arena;
#![crate_name = "rustc_bitflags"]
-#![feature(associated_consts)]
#![crate_type = "rlib"]
#![no_std]
#![deny(warnings)]
+#![cfg_attr(stage0, feature(associated_consts))]
+
//! A typesafe bitmask flag generator.
#[cfg(test)]
///
/// ```{.rust}
/// #![feature(rustc_private)]
-/// #![feature(associated_consts)]
/// #[macro_use] extern crate rustc_bitflags;
///
/// bitflags! {
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
-#![feature(associated_consts)]
+
+#![cfg_attr(stage0, feature(associated_consts))]
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
#![feature(nonzero)]
#![feature(unboxed_closures)]
#![feature(fn_traits)]
-#![feature(associated_consts)]
#![feature(unsize)]
#![feature(i128_type)]
#![feature(conservative_impl_trait)]
#![feature(specialization)]
#![feature(manually_drop)]
+#![cfg_attr(stage0, feature(associated_consts))]
#![cfg_attr(stage0, feature(struct_field_attributes))]
#![cfg_attr(unix, feature(libc))]
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]
-#![feature(associated_consts)]
#![feature(box_syntax)]
#![feature(concat_idents)]
#![feature(libc)]
#![feature(link_args)]
#![feature(static_nobundle)]
+#![cfg_attr(stage0, feature(associated_consts))]
+
extern crate libc;
#[macro_use]
#[no_link]
#![crate_type = "dylib"]
#![deny(warnings)]
-#![feature(associated_consts)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(i128_type)]
#![feature(collection_placement)]
#![feature(nonzero)]
+#![cfg_attr(stage0, feature(associated_consts))]
+
#[macro_use] extern crate log;
extern crate graphviz as dot;
#[macro_use]
Erroneous code example:
```compile_fail,E0438
-#![feature(associated_consts)]
-
trait Foo {}
impl Foo for i32 {
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]
-#![feature(associated_consts)]
#![feature(rustc_diagnostic_macros)]
+#![cfg_attr(stage0, feature(associated_consts))]
+
#[macro_use]
extern crate log;
#[macro_use]
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![deny(warnings)]
-#![feature(associated_consts)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(const_fn)]
#![feature(slice_patterns)]
#![feature(conservative_impl_trait)]
+#![cfg_attr(stage0, feature(associated_consts))]
+
use rustc::dep_graph::WorkProduct;
use syntax_pos::symbol::Symbol;
Erroneous code example:
```compile_fail,E0323
-#![feature(associated_consts)]
-
trait Foo {
type N;
}
Or:
```
-#![feature(associated_consts)]
-
struct Bar;
trait Foo {
code example:
```compile_fail,E0324
-#![feature(associated_consts)]
-
struct Bar;
trait Foo {
verify that you are indeed implementing the correct trait items. Example:
```
-#![feature(associated_consts)]
-
struct Bar;
trait Foo {
Erroneous code example:
```compile_fail,E0325
-#![feature(associated_consts)]
-
struct Bar;
trait Foo {
Or:
```
-#![feature(associated_consts)]
-
struct Bar;
trait Foo {
Here's an example of this error:
```compile_fail,E0326
-#![feature(associated_consts)]
-
trait Foo {
const BAR: bool;
}
error is shown below:
```
-#![feature(associated_consts)]
-
trait Foo {
const BAR: f64;
}
through a concrete type, as shown below:
```
-#![feature(associated_consts)]
-
trait Foo {
const BAR: f64;
}
#![feature(allocator_internals)]
#![feature(allow_internal_unstable)]
#![feature(asm)]
-#![feature(associated_consts)]
#![feature(box_syntax)]
#![feature(cfg_target_has_atomic)]
#![feature(cfg_target_thread_local)]
#![cfg_attr(test, feature(float_bits_conv))]
#![cfg_attr(not(stage0), default_lib_allocator)]
+#![cfg_attr(stage0, feature(associated_consts))]
// Explicitly import the prelude. The compiler uses this same unstable attribute
// to import the prelude implicitly when building crates that depend on std.
// #23121. Array patterns have some hazards yet.
(active, slice_patterns, "1.0.0", Some(23121)),
- // Allows the definition of associated constants in `trait` or `impl`
- // blocks.
- (active, associated_consts, "1.0.0", Some(29646)),
-
// Allows the definition of `const fn` functions.
(active, const_fn, "1.2.0", Some(24111)),
(accepted, closure_to_fn_coercion, "1.19.0", Some(39817)),
// Allows attributes on struct literal fields.
(accepted, struct_field_attributes, "1.20.0", Some(38814)),
+ // Allows the definition of associated constants in `trait` or `impl`
+ // blocks.
+ (accepted, associated_consts, "1.20.0", Some(29646)),
);
// If you change this, please modify src/doc/unstable-book as well. You must
fn visit_trait_item(&mut self, ti: &'a ast::TraitItem) {
match ti.node {
- ast::TraitItemKind::Const(..) => {
- gate_feature_post!(&self, associated_consts,
- ti.span,
- "associated constants are experimental")
- }
ast::TraitItemKind::Method(ref sig, ref block) => {
if block.is_none() {
self.check_abi(sig.abi, ti.span);
}
match ii.node {
- ast::ImplItemKind::Const(..) => {
- gate_feature_post!(&self, associated_consts,
- ii.span,
- "associated constants are experimental")
- }
ast::ImplItemKind::Method(ref sig, _) => {
if sig.constness.node == ast::Constness::Const {
gate_feature_post!(&self, const_fn, ii.span, "const fn is unstable");
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
pub use self::sub::{Bar, Baz};
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
enum Foo {}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait Bar {}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait Foo {
const ID: i32;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait Foo {
const ID: usize;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
#![deny(dead_code)]
struct MyFoo;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait Foo {
type Out: Sized;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait Foo {
const NAME: &'static str;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait Foo {
const BAR: u32; //~ NOTE type in trait
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait Foo {
const ID: i32;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
mod bar1 {
pub use self::bar2::Foo;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
pub enum EFoo { A, B, C, D }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
pub trait Foo {
const Y: usize;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
pub trait Foo {
const Y: usize;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
#![deny(non_upper_case_globals)]
#![allow(dead_code)]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
struct Foo;
// Test for issue #23969
-#![feature(associated_consts)]
trait Foo {
type Ty;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
#![feature(associated_type_defaults)]
pub trait Tr {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
pub trait Trait {
const CONST: u32;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
pub use self::sub::{Bar, Baz};
+++ /dev/null
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// gate-test-associated_consts
-
-trait MyTrait {
- const C: bool;
- //~^ associated constants are experimental
-}
-
-struct Foo;
-
-impl Foo {
- const C: bool = true;
- //~^ associated constants are experimental
-}
// Can't use constants as tuple struct patterns
-#![feature(associated_consts)]
const C1: i32 = 0;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
enum Enum<T: Trait> {
X = Trait::Number,
// aux-build:issue_41549.rs
-#![feature(associated_consts)]
extern crate issue_41549;
// Check that we correctly prevent users from making trait objects
// from traits with associated consts.
-#![feature(associated_consts)]
trait Bar {
const X: usize;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
#![feature(optin_builtin_traits)]
trait MarkerTr {}
// Private types and traits are not allowed in public interfaces.
// This test also ensures that the checks are performed even inside private modules.
-#![feature(associated_consts)]
#![feature(associated_type_defaults)]
#![deny(private_in_public)]
#![allow(unused)]
// Private types and traits are not allowed in public interfaces.
// This test also ensures that the checks are performed even inside private modules.
-#![feature(associated_consts)]
#![feature(associated_type_defaults)]
mod types {
// except according to those terms.
#![feature(custom_attribute)]
-#![feature(associated_consts)]
macro_rules! stmt_mac {
() => {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait A { }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
#![feature(associated_type_defaults)]
struct S;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
use Trait::foo;
//~^ ERROR `foo` is not directly importable
#![crate_type="rlib"]
#![feature(associated_type_defaults)]
#![feature(intrinsics)]
-#![feature(associated_consts)]
// Change trait visibility --------------------------------------------------------
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait Foo {
const NUM: usize;
// aux-build:associated-const-cc-lib.rs
-#![feature(associated_consts)]
extern crate associated_const_cc_lib as foolib;
// aux-build:associated-const-cc-lib.rs
-#![feature(associated_consts)]
extern crate associated_const_cc_lib as foolib;
// aux-build:associated-const-cc-lib.rs
-#![feature(associated_consts)]
extern crate associated_const_cc_lib as foolib;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
struct Foo;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
struct Foo;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
#![deny(dead_code)]
// aux-build:empty-struct.rs
-#![feature(associated_consts)]
extern crate empty_struct;
use empty_struct::XEmpty2 as XFoo;
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait Lattice {
const BOTTOM: Self;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait Foo {
const ID: i32 = 2;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
mod bar1 {
pub use self::bar2::Foo;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
struct Foo;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
struct MyType;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait MyInt {
const ONE: Self;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait Foo {
const X: i32;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait Foo {
const ID: i32;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait Foo {
const ID: i32 = 1;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
// The main purpose of this test is to ensure that different impls of the same
// trait can refer to each other without setting off the static recursion check
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait Foo {
const ID: i32;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
#![crate_type="lib"]
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
#![deny(dead_code)]
// use different types / traits to test all combinations
// #24947 ICE using a trait-associated const in an array size
-#![feature(associated_consts)]
struct Foo;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
struct S;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait HasNumber<T> {
const Number: usize;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
#[derive(Clone, Copy, Debug)]
struct Bar;
// Regression test for issue #31267
-#![feature(associated_consts)]
struct Foo;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
macro_rules! m { () => { 0 } }
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
pub trait Foo {
// @has assoc_consts/trait.Foo.html '//*[@class="rust trait"]' \
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
pub trait Foo {
const FOO: usize;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
use std::marker::PhantomData;
// except according to those terms.
#![feature(associated_type_defaults)]
-#![feature(associated_consts)]
// @has issue_28478/trait.Bar.html
pub trait Bar {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts, associated_types)]
-
// Test that associated item impls on primitive types don't crash rustdoc
pub trait Foo {
// Ensure constant and array length values are not taken from source
// code, which wreaks havoc with macros.
-#![feature(associated_consts)]
macro_rules! make {
($n:expr) => {
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
pub trait X {
const CONSTANT: u32;
// aux-build:m1.rs
-#![feature(associated_consts)]
extern crate m1;
error[E0601]: main function not found
error[E0046]: not all trait items implemented, missing: `CONSTANT`, `Type`, `method`
- --> $DIR/m2.rs:20:1
+ --> $DIR/m2.rs:19:1
|
-20 | / impl m1::X for X {
-21 | | }
+19 | / impl m1::X for X {
+20 | | }
| |_^ missing `CONSTANT`, `Type`, `method` in implementation
|
= note: `CONSTANT` from trait: `const CONSTANT: u32;`
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
use std::fmt::Debug;
error[E0437]: type `bar` is not a member of trait `Foo`
- --> $DIR/impl-wrong-item-for-trait.rs:47:5
+ --> $DIR/impl-wrong-item-for-trait.rs:46:5
|
-47 | type bar = u64;
+46 | type bar = u64;
| ^^^^^^^^^^^^^^^ not a member of trait `Foo`
error[E0323]: item `bar` is an associated const, which doesn't match its trait `Foo`
- --> $DIR/impl-wrong-item-for-trait.rs:25:5
+ --> $DIR/impl-wrong-item-for-trait.rs:24:5
|
-16 | fn bar(&self);
+15 | fn bar(&self);
| -------------- item in trait
...
-25 | const bar: u64 = 1;
+24 | const bar: u64 = 1;
| ^^^^^^^^^^^^^^^^^^^ does not match trait
error[E0046]: not all trait items implemented, missing: `bar`
- --> $DIR/impl-wrong-item-for-trait.rs:22:1
+ --> $DIR/impl-wrong-item-for-trait.rs:21:1
|
-16 | fn bar(&self);
+15 | fn bar(&self);
| -------------- `bar` from trait
...
-22 | / impl Foo for FooConstForMethod {
-23 | | //~^ ERROR E0046
-24 | | //~| NOTE missing `bar` in implementation
-25 | | const bar: u64 = 1;
+21 | / impl Foo for FooConstForMethod {
+22 | | //~^ ERROR E0046
+23 | | //~| NOTE missing `bar` in implementation
+24 | | const bar: u64 = 1;
... |
-28 | | const MY_CONST: u32 = 1;
-29 | | }
+27 | | const MY_CONST: u32 = 1;
+28 | | }
| |_^ missing `bar` in implementation
error[E0324]: item `MY_CONST` is an associated method, which doesn't match its trait `Foo`
- --> $DIR/impl-wrong-item-for-trait.rs:37:5
+ --> $DIR/impl-wrong-item-for-trait.rs:36:5
|
-17 | const MY_CONST: u32;
+16 | const MY_CONST: u32;
| -------------------- item in trait
...
-37 | fn MY_CONST() {}
+36 | fn MY_CONST() {}
| ^^^^^^^^^^^^^^^^ does not match trait
error[E0046]: not all trait items implemented, missing: `MY_CONST`
- --> $DIR/impl-wrong-item-for-trait.rs:33:1
+ --> $DIR/impl-wrong-item-for-trait.rs:32:1
|
-17 | const MY_CONST: u32;
+16 | const MY_CONST: u32;
| -------------------- `MY_CONST` from trait
...
-33 | / impl Foo for FooMethodForConst {
-34 | | //~^ ERROR E0046
-35 | | //~| NOTE missing `MY_CONST` in implementation
-36 | | fn bar(&self) {}
+32 | / impl Foo for FooMethodForConst {
+33 | | //~^ ERROR E0046
+34 | | //~| NOTE missing `MY_CONST` in implementation
+35 | | fn bar(&self) {}
... |
-39 | | //~| NOTE does not match trait
-40 | | }
+38 | | //~| NOTE does not match trait
+39 | | }
| |_^ missing `MY_CONST` in implementation
error[E0325]: item `bar` is an associated type, which doesn't match its trait `Foo`
- --> $DIR/impl-wrong-item-for-trait.rs:47:5
+ --> $DIR/impl-wrong-item-for-trait.rs:46:5
|
-16 | fn bar(&self);
+15 | fn bar(&self);
| -------------- item in trait
...
-47 | type bar = u64;
+46 | type bar = u64;
| ^^^^^^^^^^^^^^^ does not match trait
error[E0046]: not all trait items implemented, missing: `bar`
- --> $DIR/impl-wrong-item-for-trait.rs:44:1
+ --> $DIR/impl-wrong-item-for-trait.rs:43:1
|
-16 | fn bar(&self);
+15 | fn bar(&self);
| -------------- `bar` from trait
...
-44 | / impl Foo for FooTypeForMethod {
-45 | | //~^ ERROR E0046
-46 | | //~| NOTE missing `bar` in implementation
-47 | | type bar = u64;
+43 | / impl Foo for FooTypeForMethod {
+44 | | //~^ ERROR E0046
+45 | | //~| NOTE missing `bar` in implementation
+46 | | type bar = u64;
... |
-50 | | const MY_CONST: u32 = 1;
-51 | | }
+49 | | const MY_CONST: u32 = 1;
+50 | | }
| |_^ missing `bar` in implementation
error[E0046]: not all trait items implemented, missing: `fmt`
- --> $DIR/impl-wrong-item-for-trait.rs:53:1
+ --> $DIR/impl-wrong-item-for-trait.rs:52:1
|
-53 | / impl Debug for FooTypeForMethod {
-54 | | }
+52 | / impl Debug for FooTypeForMethod {
+53 | | }
| |_^ missing `fmt` in implementation
|
= note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>`
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(associated_consts)]
trait Tr {
const C: Self;
error[E0277]: the trait bound `u8: Tr` is not satisfied
- --> $DIR/issue-29595.rs:18:17
+ --> $DIR/issue-29595.rs:17:17
|
-18 | let a: u8 = Tr::C; //~ ERROR the trait bound `u8: Tr` is not satisfied
+17 | let a: u8 = Tr::C; //~ ERROR the trait bound `u8: Tr` is not satisfied
| ^^^^^ the trait `Tr` is not implemented for `u8`
|
= note: required by `Tr::C`