Naming convention query: `Vec` vs `Vector`
Hello,
I have been studying petsc-rs, and learning lots from it.
One particular thing I didn't understand is why PETSc Vec
was converted to Vector
in petsc-rs.
My guess is, this decision to rename Vec
to Vector
was to prevent name collision with rust's own std::vec::Vec
or simply Vec
.
If so, I understand the reasoning, but it could be avoided.
If PETSc devs would find value in retaining the original names of structs and functions as much as possible in rust, then a technique like this might be helpful.
I myself, re-export the important structs from rust's standard library, including Vec
, into a new namespace stl
.
// @file: stl.rs
#![allow(unused_imports)]
pub use std::boxed::Box;
pub use std::vec::Vec;
pub use std::rc::Rc;
pub use std::rc::Weak;
Similarly, my own version of Vec
is re-exported into another namespace nox
.
// @file: nox.rs
#![allow(unused_imports)]
pub use crate::core::spvec::SpVec;
pub use crate::core::vec::Vec;
This allows me to use both versions of Vec
in my code as in..
use crate::nox;
use crate::stl;
#[derive(Debug)]
pub struct Su2Mesh {
num_dims: u32,
num_cells: u32,
num_nodes: u32,
num_marks: u32,
cells: nox::SpVec<u32>,
nodes: nox::Vec<[f64; 3]>,
markers: stl::Vec<&str>,
}
I find using nox::Vec
and stl::Vec
easy to use.
They can't exist in the same namespace, but they don't need to.
petsc-rs tried to prevent the name collision with Vec
by renaming to Vector
, but it's most likely that rust devs world wide will implement their own Vector
to use for either geometrical operations or array operations.
Then their Vector
will collide with petsc-rs's Vector
.
Similarly Mat
may also collide.
So, I think retaining PETSc's original Vec
name may be beneficial for users.
Thanks!