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

add story about nalgebra #19

Merged
merged 6 commits into from
Feb 16, 2022
Merged

add story about nalgebra #19

merged 6 commits into from
Feb 16, 2022

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented Feb 11, 2022

No description provided.

With this change, `nalgebra` needs impls like the following

```rust
impl<T, const R: usize, const C: usize> for SMatrix<T, R, C> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work if the type alias were expanded manually here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, we still only see ConstKind::Unevaluated in the self type

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this case a problem then? For the later cases with exhaustive impls?

Copy link
Contributor Author

@lcnr lcnr Feb 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because you can't write that impl

#![feature(adt_const_params, generic_const_exprs)]

struct Foo<const N: Option<usize>>;

impl<const N: usize> Foo<{ Some(N) }> {}

results in

error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates
 --> src/lib.rs:5:12
  |
5 | impl<const N: usize> Foo<{ Some(N) }> {}
  |            ^ unconstrained const parameter
  |
  = note: expressions using a const parameter must map each value to a distinct output value
  = note: proving the result of expressions other than the parameter are unique is not supported

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, thanks! That's what I was hoping to be the issue, but it wasn't clear to me from the text. To make it a bit simpler, can you a) expand the type alias and b) explain that a generic constant isn't what we actually want, as that is the notion I got from your comment about "constructors being injective"

@lcnr lcnr merged commit a33bec1 into rust-lang:master Feb 16, 2022
@lcnr lcnr deleted the nalgebra branch February 16, 2022 13:07
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

Successfully merging this pull request may close these issues.

2 participants