I am trying to render text in a separate function using piston2d / piston_window. I am able to draw text just fine, but I can't figure out how to pass the appropriate parameters into a separate function.
I have studied What is GlyphCache type in a function to render text in Piston2d and adjusted my code accordingly, but I can't make sense of the error I am getting.
use piston_window::*;
fn main() {
    let font = include_bytes!("IBMPlexSans-Regular.ttf");
    let opengl = OpenGL::V3_2;
    let settings = WindowSettings::new("test", [500, 500])
        .graphics_api(opengl)
        .fullscreen(false)
        .vsync(true)
        .exit_on_esc(true);
    let mut window: PistonWindow = settings.build().unwrap();
    let mut glyphs = Glyphs::from_bytes(
        font,
        window.create_texture_context(),
        TextureSettings::new(),
    )
    .unwrap();
    while let Some(e) = window.next() {
        window.draw_2d(&e, |c, gfx, device| {
            clear([0.2; 4], gfx);
        text::Text::new_color([1.0, 1.0, 1.0, 0.7], 30)
            .draw(
                "Hi!",
                &mut glyphs,
                &c.draw_state,
                c.transform
                    .trans(100., 100.),
                gfx,
            )
            .unwrap();
            glyphs.factory.encoder.flush(device);
        });
    }
}
fn render_text(
    x: f64,
    y: f64,
    text: &str,
    size: u32,
    c: Context,
    g: &mut G2d,
    glyphs: &mut glyph_cache::rusttype::GlyphCache<GfxFactory, G2dTexture>,
) {
    text::Text::new(size)
        .draw(text, glyphs, &c.draw_state, c.transform.trans(x, y), g)
        .unwrap();
}
I am receiving the following error:
error[E0277]: the trait bound `Texture<gfx_device_gl::Resources>: UpdateTexture<gfx_device_gl::factory::Factory>` is not satisfied
  --> src/main.rs:54:10
   |
54 |         .draw(text, glyphs, &c.draw_state, c.transform.trans(x, y), g)
   |          ^^^^ the trait `UpdateTexture<gfx_device_gl::factory::Factory>` is not implemented for `Texture<gfx_device_gl::Resources>`
   |
   = help: the following implementations were found:
             <Texture<R> as UpdateTexture<TextureContext<F, R, C>>>
   = note: required because of the requirements on the impl of `CharacterCache` for `GlyphCache<'_, gfx_device_gl::factory::Factory, Texture<gfx_device_gl::Resources>>`
I am aware this is probably very piston-specific, but I would be very happy about any pointers.