Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blocking rust features #7

Open
Emoun opened this issue Mar 29, 2021 · 3 comments
Open

Blocking rust features #7

Emoun opened this issue Mar 29, 2021 · 3 comments

Comments

@Emoun
Copy link
Owner

Emoun commented Mar 29, 2021

This issue tracks all rust features that are blocking further progress on this crate.

Equality constraints on associated constants

This will allow directeness to be an associated constant instead of the the current trait+structs API:

// Trait definition
trait Graph{
  ...
  const DIRECTED: bool;
  ...
}

// Impl example:
impl Graph for Struct{
  ...
  const DIRECTED: bool = true;
  ...
}

// Trait bounds
fn func<G: Graph<DIRECTED=true>>(g: &G){...}

// Usage
fn directed<G: Graph>(g: &G) -> bool {
  G::DIRECTED
}

type_alias_impl_trait & generic_associated_types

This would allow the result types of most Graph methods to be impl Iterator, such that implementors can use whatever implementation they want.
To achieve this currently we are using Box<Iterator> as return types which is inefficient.

@Emoun
Copy link
Owner Author

Emoun commented Nov 5, 2022

Now that GATs have been stabilized, on nightly we can redesign the Graph methods to use associated types with impl Trait to about boxing.

However, right now I'm experiencing this issue when using impl Borrow<Self::Vertex> as vertex arguments to functions.
This might not be a hard blocker, as the workaround is to either take the vertices as owned argument or references. However, impl Borrow<Self::Vertex> is preferable for usability.

@Emoun
Copy link
Owner Author

Emoun commented Nov 5, 2022

We have a problem with using GATs + impl Trait:

We have optional methods that also use the GATs to define their return iterator type.
However, when not implementing these functions manually, we have to give the iterator GAT a type. If we try to give it impl ... type, without using it anywhere, we get the error: unconstrained opaque type ... must be used in combination with a concrete type within the same impl.
It therefore seems impossible to use optional methods with GATs + impl type. Even if we use associate type defaults, where we set the default to impl .. we get an error 'impl Trait' only allowed in function and inherent method return types, not in type.
So, at best we need associate type default, but it will only work if it allows impl in the default.

@Emoun
Copy link
Owner Author

Emoun commented Oct 30, 2024

The newest version of Rust now allows impl trait in trait return position. This means we are no longer dependent on TAI or GATs as stated above. This issue is therefore solved. See 05acd06.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant