MCPcopy Create free account
hub / github.com/IntegralPilot/rustc_codegen_jvm / main

Function main

tests/binary/traits/src/main.rs:90–174  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

88struct I64Source {
89 next: i64,
90}
91
92impl DynSource for I64Source {
93 type Item = i64;
94
95 fn next_value(&mut self) -> Option<Self::Item> {
96 let value = self.next;
97 self.next += 2;
98 Some(value)
99 }
100}
101
102fn next_i32(source: &mut dyn DynSource<Item = i32>) -> i32 {
103 source.next_value().unwrap()
104}
105
106fn next_i64(source: &mut dyn DynSource<Item = i64>) -> i64 {
107 source.next_value().unwrap()
108}
109
110impl PrimitiveTraitObject for i32 {
111 fn doubled(&self) -> i32 {
112 *self * 2
113 }
114}
115
116impl<T: PrimitiveTraitObject + ?Sized> PrimitiveTraitObject for &T {
117 fn doubled(&self) -> i32 {
118 (**self).doubled()
119 }
120}
121
122fn use_primitive_trait_object(value: &dyn PrimitiveTraitObject) -> i32 {
123 value.doubled()
124}
125
126fn drop_send_from_any(value: &(dyn core::any::Any + Send)) -> &dyn core::any::Any {
127 value
128}
129
130// --- First Implementation ---
131struct SimpleAdder {
132 current_total: i32,
133}
134
135impl Calculator for SimpleAdder {
136 fn calculate(&self, a: i32, b: i32) -> i32 {
137 a + b // Simple addition
138 }
139
140 fn accumulate(&mut self, value: i32) {
141 self.current_total += value;
142 }
143
144 fn get_value(&self) -> i32 {
145 self.current_total
146 }
147

Callers

nothing calls this directly

Calls 4

perform_calculationFunction · 0.85
check_propertiesFunction · 0.85
update_stateFunction · 0.85
accumulateMethod · 0.80

Tested by

no test coverage detected