pub fn path_to_segments(path: &str) -> Vec<&str> {
    /*
     * We're given the "path" portion of a URI and we want to construct an
     * array of the segments of the path.   Relevant references:
     *
     *    RFC 7230 HTTP/1.1 Syntax and Routing
     *             (particularly: 2.7.3 on normalization)
     *    RFC 3986 Uniform Resource Identifier (URI): Generic Syntax
     *             (particularly: 6.2.2 on comparison)
     *
     * TODO-hardening We should revisit this.  We want to consider a few things:
     * - whether our input is already (still?) percent-encoded or not
     * - whether our returned representation is percent-encoded or not
     * - what it means (and what we should do) if the path does not begin with
     *   a leading "/"
     * - whether we want to collapse consecutive "/" characters (presumably we
     *   do, both at the start of the path and later)
     * - how to handle paths that end in "/" (in some cases, ought this send a
     *   300-level redirect?)
     * - are there other normalization considerations? e.g., ".", ".."
     *
     * It seems obvious to reach for the Rust "url" crate. That crate parses
     * complete URLs, which include a scheme and authority section that does
     * not apply here. We could certainly make one up (e.g.,
     * "http://127.0.0.1") and construct a URL whose path matches the path we
     * were given. However, while it seems natural that our internal
     * representation would not be percent-encoded, the "url" crate
     * percent-encodes any path that it's given. Further, we probably want to
     * treat consecutive "/" characters as equivalent to a single "/", but that
     * crate treats them separately (which is not unreasonable, since it's not
     * clear that the above RFCs say anything about whether empty segments
     * should be ignored). The net result is that that crate doesn't buy us
     * much here, but it does create more work, so we'll just split it
     * ourselves.
     */
    path.split('/').filter(|segment| !segment.is_empty()).collect::<Vec<_>>()
}
/**
 * Helper function for taking a Uri path and producing a `Vec<String>` of
 * URL-encoded strings, each representing one segment of the path.
 */
Helper function for taking a Uri path and producing a `Vec` of
URL-encoded strings, each representing one segment of the path.
Helper function for taking a Uri path and producing a ` Vec ` of URL - encoded strings each representing one segment of the path .
pub fn path_to_segments(path: &str) -> Vec<&str> {
    /*
     * We're given the "path" portion of a URI and we want to construct an
     * array of the segments of the path.   Relevant references:
     *
     *    RFC 7230 HTTP/1.1 Syntax and Routing
     *             (particularly: 2.7.3 on normalization)
     *    RFC 3986 Uniform Resource Identifier (URI): Generic Syntax
     *             (particularly: 6.2.2 on comparison)
     *
     * TODO-hardening We should revisit this.  We want to consider a few things:
     * - whether our input is already (still?) percent-encoded or not
     * - whether our returned representation is percent-encoded or not
     * - what it means (and what we should do) if the path does not begin with
     *   a leading "/"
     * - whether we want to collapse consecutive "/" characters (presumably we
     *   do, both at the start of the path and later)
     * - how to handle paths that end in "/" (in some cases, ought this send a
     *   300-level redirect?)
     * - are there other normalization considerations? e.g., ".", ".."
     *
     * It seems obvious to reach for the Rust "url" crate. That crate parses
     * complete URLs, which include a scheme and authority section that does
     * not apply here. We could certainly make one up (e.g.,
     * "http://127.0.0.1") and construct a URL whose path matches the path we
     * were given. However, while it seems natural that our internal
     * representation would not be percent-encoded, the "url" crate
     * percent-encodes any path that it's given. Further, we probably want to
     * treat consecutive "/" characters as equivalent to a single "/", but that
     * crate treats them separately (which is not unreasonable, since it's not
     * clear that the above RFCs say anything about whether empty segments
     * should be ignored). The net result is that that crate doesn't buy us
     * much here, but it does create more work, so we'll just split it
     * ourselves.
     */
    path.split('/').filter(|segment| !segment.is_empty()).collect::<Vec<_>>()
}
pub fn path_to_segments ( path : & str ) -> Vec < & str > { /*
     * We're given the "path" portion of a URI and we want to construct an
     * array of the segments of the path.   Relevant references:
     *
     *    RFC 7230 HTTP/1.1 Syntax and Routing
     *             (particularly: 2.7.3 on normalization)
     *    RFC 3986 Uniform Resource Identifier (URI): Generic Syntax
     *             (particularly: 6.2.2 on comparison)
     *
     * TODO-hardening We should revisit this.  We want to consider a few things:
     * - whether our input is already (still?) percent-encoded or not
     * - whether our returned representation is percent-encoded or not
     * - what it means (and what we should do) if the path does not begin with
     *   a leading "/"
     * - whether we want to collapse consecutive "/" characters (presumably we
     *   do, both at the start of the path and later)
     * - how to handle paths that end in "/" (in some cases, ought this send a
     *   300-level redirect?)
     * - are there other normalization considerations? e.g., ".", ".."
     *
     * It seems obvious to reach for the Rust "url" crate. That crate parses
     * complete URLs, which include a scheme and authority section that does
     * not apply here. We could certainly make one up (e.g.,
     * "http://127.0.0.1") and construct a URL whose path matches the path we
     * were given. However, while it seems natural that our internal
     * representation would not be percent-encoded, the "url" crate
     * percent-encodes any path that it's given. Further, we probably want to
     * treat consecutive "/" characters as equivalent to a single "/", but that
     * crate treats them separately (which is not unreasonable, since it's not
     * clear that the above RFCs say anything about whether empty segments
     * should be ignored). The net result is that that crate doesn't buy us
     * much here, but it does create more work, so we'll just split it
     * ourselves.
     */ path . split ( '/' ) . filter ( | segment | ! segment . is_empty ( ) ) . collect :: < Vec < _ > > ( ) }
Helper function for taking a Uri path and producing a `Vec<String>` of
 URL-encoded strings, each representing one segment of the path.
Helper function for taking a Uri path and producing a ` Vec<String > ` of URL - encoded strings each representing one segment of the path .
path
&str
path
&str