Use references for scalar operands

Ouverte
#1,200 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
35/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
rust
Domaine
data

Piste de recherche

Start by tracing the ops macros and the ScalarOperand and StaticOperand implementations mentioned in the issue, then reproduce the array-plus-referenced-scalar example. Investigate the conflicting implementation error and existing operand combinations. Done means the example compiles while existing array operation behavior remains supported.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

It would be useful for me to be able to use references to scalars instead of owned instances when performing operations on arrays.

e.g., this fails:

let arr1 = array!([1, 2, 3]);
let four: i32 = 4;
let arr2 = arr1 + &four; //error

I naively tried modifying the ops macros to accept references but kept getting a conflicting implementation error. It seems that the compiler is worried that someone will come along an add an implementation to StaticOperand for reference types:

    = note: downstream crates may implement trait `impl_ops::ScalarOperand` for type `&_`

...which is strange because there's a 'static type bound on ScalarOperand?

In any case, if anyone has any guidance on how to proceed, I'd greatly appreciate it! I'm happy to open a PR with a nudge in the right direction.

Langage dominant
Rust
Étoiles
4.3k
Forks
391
Métriques de merge des PR
Aucune PR mergée en 30 j

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de rust-ndarray/ndarray

Toutes les issues de rust-ndarray/ndarray

Issues similaires

Plus d'issues Rust

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.