Skip to content

Importing/Exporting an impl (not type) from another module #2393

Closed
@erickt

Description

@erickt

Perhaps I'm trying to be too fancy. I'm writing an app that uses a generic type from a library called request<T> seen here. It comes with an iface/impl named request that adds a couple functions to the request. My app only needs one instance of this type, so I created a module like this:

import mre_request = mre::request::request;

export mre_request;
export request;
export request_data;

type request_data = {
    mut session: option<mre::session::session>,
    mut user: option<mre::user::user>,
};

type request = mre::request::request<request_data>;

This doesn't quite the interface I'd like though. The users of this library have to do import request::{request, mre_request} in order to get the type and impl in scope. I'd much rather my other parts of the app just do import request::request to get the type/impl. Is there any way to simplify this down? Maybe we could allow importing/exporting just the impl from a module? Or maybe we could allow exporting just a single instantiated type, as in:

import mre::request::request;

export request_data;
export request = request<request_data>;

type request_data = {
    mut session: option<mre::session::session>,
    mut user: option<mre::user::user>,
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesA-type-systemArea: Type systemC-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions