Add docs on how to write a function for both owned arrays and views

Abierto
#1,212 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
35/100
Tipo de issue
Documentación
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
rust

Línea de trabajo

Review the existing ndarray documentation and the linked Stack Overflow example first. Determine the recommended way to write a function accepting both owned arrays and views, then document that pattern with a comparable example and make the guidance clear for both cases.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

docs

I'm currently trying to write a function that can take either an owned array or a view. I'm currently relying on this stackoverflow post to do something like:

use ndarray::{ArrayBase, RawData, s, array, Ix1};

fn do_something_with_array<S>(a: &ArrayBase<S, Ix1>) where S: RawData{

}

fn main () {
    let a = array![1, 2, 3];
    do_something_with_array(&a);

    let slc = a.slice(s![1..3]);
    do_something_with_array(&slc);
}

I'm not sure if this is the best way though (certainly having to include a type parameter in the function definition seems clunky), so it would be good to get clarification and add a section to the docs explaining how to write these functions.

Lenguaje dominante
Rust
Estrellas
4.3k
Forks
391
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rust-ndarray/ndarray

Todos los issues de rust-ndarray/ndarray

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.