ITADN

H-5235: Replace `attach` -> `attach_opaque` and `attach_printable` -> `attach`

#7742Openmkatychev 创建于 2025-08-22
area/libs > error-stackarea/libslang/rustcategory/enhancement
M
mkatychevcommented
### Related Problem I've often noticed that most new users that I've introduced (and sometimes myself as well) assume that `::attach` methods would show up in stdout and are suprised by the default behaviour. Would it make sense for the more verbose variant to be the one that behaves in a more specific way? Anecdotally, most attachments are ones that I would want to be visible in the stack trace. ### Proposed Solution It would be nice to ideally rename `::attach` -> `::attach_opaque` and `::attach_printable` -> `::attach` but that would be a very breaking change. Could an alias be introduced that makes the opaque attachment behaviour more explicit? ```rs #[track_caller] pub fn attach<A>(mut self, attachment: A) -> Self where A: Send + Sync + 'static, { // ... self } pub fn attach_opaque<A>(mut self, attachment: A) -> Self where A: fmt::Display + fmt::Debug + Send + Sync + 'static, { self.attach(attachment) } ``` ### Alternatives _No response_ ### Additional context _No response_
3 条评论