Lots of questions.

1. Is there an array string join function?  I looked through possible
    pertinent vector- and string-related modules and I didn't see
    something equivalent.


2. Any particular reason to_str() for arrays (defined in in std::to_str)
   is defined only for unique arrays? i.e.
        impl<A: ToStr> ~[A]: ToStr {
            // ...
        }
   rather than for all array types via &?
        impl<A: ToStr> &[A]: ToStr {
            // ...
        }
   Modifying the definition seems to allow it to work for managed and static
   arrays.


3. What is the rust idiom for defining a constant value associated with a
   class? As an example, I defined N below for the vector class in C++ and
   immediately used it to define data members.
        struct Vector3<T> {
            enum { N = 3 };
            T m_v[N];
        };

   In static contexts like above, especially when there may be multiple data
   members dependent on the constant, I just wanted to associate a name with
   them. I am already defining a len() method as below to return this value.
        struct Vector3<T> {
            priv m_v: [mut T * 3]
        }

        impl<T> Vector3<T> {
            fn len(&self) -> uint { 3u; }
        }
    Rust does not seem to allow adding const definitions inside the struct.


4. How do I copy between mutable/immutable types and from dynamic to static
   array types?
    let a : ~[int] = ~[1,2,3];
    // I know these are by design, but I don't know how to get the desired
    // effect.
    let b : [int * 3] = copy a; // fails due to storage mismatch
    let c : ~[mut int] = copy a; // fails due to mutability mismatch


5. Consistency of len/size:
   Each language seems to have its own standard for specifying container
   size. I thought Rust's convention was len from vector, dvec, list, etc,
   but deque uses size.  Should that also be len?  Or rather, as "size" is
   the more generic term (applies semantically to arbitrary containers like
   trees and maps), should "size" be the standard? Or, like ruby, perhaps
   both could be allowed.


6. Is there any way to get a number into a macro and splice it into a class
   name? i.e. Something like the intention behind the following.
        macro_rules! VectorT {
            // invoke it like VectorT<N>
            ($name:ident, $n:expr) => (
                struct Vector$n<T> {
                    priv m_v: [mut T * $n];
                }
            );
        }
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to