]> git.lizzy.rs Git - rust.git/blob - src/test/ui/lifetimes/bare-trait-object-borrowck.rs
Rollup merge of #105555 - krasimirgg:llvm-int-opt-2, r=cuviper
[rust.git] / src / test / ui / lifetimes / bare-trait-object-borrowck.rs
1 #![allow(bare_trait_objects)]
2 // check-pass
3 pub struct FormatWith<'a, I, F> {
4     sep: &'a str,
5     /// FormatWith uses interior mutability because Display::fmt takes &self.
6     inner: RefCell<Option<(I, F)>>,
7 }
8
9 use std::cell::RefCell;
10 use std::fmt;
11
12 struct Layout;
13
14 pub fn new_format<'a, I, F>(iter: I, separator: &'a str, f: F) -> FormatWith<'a, I, F>
15 where
16     I: Iterator,
17     F: FnMut(I::Item, &mut FnMut(&fmt::Display) -> fmt::Result) -> fmt::Result,
18 {
19     FormatWith { sep: separator, inner: RefCell::new(Some((iter, f))) }
20 }
21
22 fn main() {
23     let _ = new_format(0..32, " | ", |i, f| f(&format_args!("0x{:x}", i)));
24 }