rust - "parameter `'a` is never used" error when 'a is used in type parameter bound -
use std::iter::iterator; trait listterm<'a> { type iter:iterator<item=&'a u32>; fn iter(&'a self)-> self::iter; } enum termvalue<'a, lt> lt:listterm<'a>+sized+'a { str(lt) } src/lib.rs:8:16: 8:18 error: parameter `'a` never used [e0392] src/lib.rs:8 enum termvalue<'a, lt> lt:listterm<'a>+'a { ^~
'a
being used. bug, or parametric enums not finished?.. rustc --explain e0392
recommends use of phantomdata<&'a _>, don't think there's opportunity in use case, may able see.
'a
being used.
not far compiler concerned. cares of generic parameters used somewhere in body of struct
or enum
. constraints do not count.
what might want use higher-ranked lifetime bound:
enum termvalue<lt> for<'a> lt: 'a + listterm<'a> + sized { str(lt) }
in other situations, might want use phantomdata
indicate want type act as though uses parameter:
use std::marker::phantomdata; struct thing<'a> { // causes type function *as though* has `&'a ()` field, // despite not *actually* having one. _marker: phantomdata<&'a ()>, }
and clear: can use phantomdata
in enum
: put in 1 of variants.
Comments
Post a Comment