#[non_exhaustive]pub enum CourseGroup {
Courses(Vec<CourseInfo>),
SubGroups(Vec<CourseGroup>),
}Expand description
Recursive course tree supporting arbitrary nesting depth.
Courses— a leaf node containing a list ofCourseInfoentriesSubGroups— a branch node containing nested sub-groups
Together with CourseGroup as the course field type, this preserves
the original JSON nesting shape round-trip:
| JSON | Rust |
|---|---|
"course": [] | Courses(vec![]) |
"course": [{...}] | Courses(vec![CourseInfo]) |
"course": [[{...}]] | SubGroups(vec![Courses(vec![CourseInfo])]) |
"course": [[{...}], [{...}]] | SubGroups(vec![Courses(..), Courses(..)]) |
"course": [[[{...}]]] | SubGroups(vec![SubGroups(vec![Courses(..)])]) |
This enum is #[non_exhaustive] — use flatten or
into_flattened to access all CourseInfo
entries without matching on variants directly.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Courses(Vec<CourseInfo>)
A leaf node containing a list of course entries.
SubGroups(Vec<CourseGroup>)
A branch node containing nested sub-groups.
Implementations§
Source§impl CourseGroup
impl CourseGroup
Sourcepub fn flatten(&self) -> Vec<&CourseInfo>
pub fn flatten(&self) -> Vec<&CourseInfo>
Flattens all CourseInfo references in this sub-tree.
Sourcepub fn into_flattened(self) -> Vec<CourseInfo>
pub fn into_flattened(self) -> Vec<CourseInfo>
Flattens this sub-tree into owned CourseInfo values.
Trait Implementations§
Source§impl Clone for CourseGroup
impl Clone for CourseGroup
Source§fn clone(&self) -> CourseGroup
fn clone(&self) -> CourseGroup
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CourseGroup
impl Debug for CourseGroup
Source§impl Default for CourseGroup
impl Default for CourseGroup
Source§impl<'de> Deserialize<'de> for CourseGroup
impl<'de> Deserialize<'de> for CourseGroup
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<CourseInfo> for CourseGroup
impl From<CourseInfo> for CourseGroup
Source§fn from(info: CourseInfo) -> Self
fn from(info: CourseInfo) -> Self
Converts to this type from the input type.
Source§impl PartialEq for CourseGroup
impl PartialEq for CourseGroup
Source§fn eq(&self, other: &CourseGroup) -> bool
fn eq(&self, other: &CourseGroup) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for CourseGroup
impl Serialize for CourseGroup
impl StructuralPartialEq for CourseGroup
Auto Trait Implementations§
impl Freeze for CourseGroup
impl RefUnwindSafe for CourseGroup
impl Send for CourseGroup
impl Sync for CourseGroup
impl Unpin for CourseGroup
impl UnsafeUnpin for CourseGroup
impl UnwindSafe for CourseGroup
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more