Skip to main content

Issues

Struct Issues 

Source
pub struct Issues { /* private fields */ }
Expand description

A collection of issues.

Implementations§

Source§

impl Issues

Source

pub fn new() -> Self

Creates a new Issues collection.

This initializes the collection with a “root” issue.

Examples found in repository?
examples/main.rs (line 7)
5fn main() {
6    // 1. Create a new Issues collection
7    let mut issues = Issues::new();
8    println!("Initial issues count: {}", issues.get_list().len());
9
10    // 2. Create a User
11    let user = User::new("Alice", "alice@example.com");
12
13    // 3. Create a new Issue
14    let mut new_issue = Issue::new("Add better documentation", user.clone(), vec!["Enhance"]);
15
16    // 4. Add a Comment to the issue
17    let comment = Comment::new("I think we should add more examples.", user.clone());
18    new_issue.comment(comment);
19
20    // 5. Add the issue to the collection
21    let issue_index = issues.add_new_issue(new_issue);
22    println!("Added new issue at index: {}", issue_index);
23
24    // 6. Print all issues
25    println!("\nAll Issues:");
26    for (i, issue) in issues.get_list().iter().enumerate() {
27        println!("Issue #{}: {:?}", i, issue);
28    }
29
30    // 7. Find an issue by title
31    if let Some(found_issues) = issues.find_from_title("documentation") {
32        println!(
33            "\nFound {} issues matching 'documentation'",
34            found_issues.len()
35        );
36    }
37
38    // 8. Fork an issue
39    if let Some(forked_index) = issues.fork(1) {
40        println!("\nForked issue #1 to new issue #{}", forked_index);
41        let forked_issue = issues.get(forked_index).unwrap();
42        println!("Forked issue details: {:?}", forked_issue);
43
44        let original_issue = issues.get(1).unwrap();
45        println!("Original issue status after fork: {:?}", original_issue);
46    }
47}
Source

pub fn add_new_issue(&mut self, i: Issue) -> usize

Adds a new issue to the collection.

Returns the index of the newly added issue.

Examples found in repository?
examples/main.rs (line 21)
5fn main() {
6    // 1. Create a new Issues collection
7    let mut issues = Issues::new();
8    println!("Initial issues count: {}", issues.get_list().len());
9
10    // 2. Create a User
11    let user = User::new("Alice", "alice@example.com");
12
13    // 3. Create a new Issue
14    let mut new_issue = Issue::new("Add better documentation", user.clone(), vec!["Enhance"]);
15
16    // 4. Add a Comment to the issue
17    let comment = Comment::new("I think we should add more examples.", user.clone());
18    new_issue.comment(comment);
19
20    // 5. Add the issue to the collection
21    let issue_index = issues.add_new_issue(new_issue);
22    println!("Added new issue at index: {}", issue_index);
23
24    // 6. Print all issues
25    println!("\nAll Issues:");
26    for (i, issue) in issues.get_list().iter().enumerate() {
27        println!("Issue #{}: {:?}", i, issue);
28    }
29
30    // 7. Find an issue by title
31    if let Some(found_issues) = issues.find_from_title("documentation") {
32        println!(
33            "\nFound {} issues matching 'documentation'",
34            found_issues.len()
35        );
36    }
37
38    // 8. Fork an issue
39    if let Some(forked_index) = issues.fork(1) {
40        println!("\nForked issue #1 to new issue #{}", forked_index);
41        let forked_issue = issues.get(forked_index).unwrap();
42        println!("Forked issue details: {:?}", forked_issue);
43
44        let original_issue = issues.get(1).unwrap();
45        println!("Original issue status after fork: {:?}", original_issue);
46    }
47}
Source

pub fn get_list(&self) -> &Vec<Issue>

Returns a reference to the list of issues.

Examples found in repository?
examples/main.rs (line 8)
5fn main() {
6    // 1. Create a new Issues collection
7    let mut issues = Issues::new();
8    println!("Initial issues count: {}", issues.get_list().len());
9
10    // 2. Create a User
11    let user = User::new("Alice", "alice@example.com");
12
13    // 3. Create a new Issue
14    let mut new_issue = Issue::new("Add better documentation", user.clone(), vec!["Enhance"]);
15
16    // 4. Add a Comment to the issue
17    let comment = Comment::new("I think we should add more examples.", user.clone());
18    new_issue.comment(comment);
19
20    // 5. Add the issue to the collection
21    let issue_index = issues.add_new_issue(new_issue);
22    println!("Added new issue at index: {}", issue_index);
23
24    // 6. Print all issues
25    println!("\nAll Issues:");
26    for (i, issue) in issues.get_list().iter().enumerate() {
27        println!("Issue #{}: {:?}", i, issue);
28    }
29
30    // 7. Find an issue by title
31    if let Some(found_issues) = issues.find_from_title("documentation") {
32        println!(
33            "\nFound {} issues matching 'documentation'",
34            found_issues.len()
35        );
36    }
37
38    // 8. Fork an issue
39    if let Some(forked_index) = issues.fork(1) {
40        println!("\nForked issue #1 to new issue #{}", forked_index);
41        let forked_issue = issues.get(forked_index).unwrap();
42        println!("Forked issue details: {:?}", forked_issue);
43
44        let original_issue = issues.get(1).unwrap();
45        println!("Original issue status after fork: {:?}", original_issue);
46    }
47}
Source

pub fn find_from_title<T: AsRef<str>>( &mut self, s: T, ) -> Option<Vec<&mut Issue>>

Finds issues containing the given title string.

Returns Some(Vec<&mut Issue>) if matches are found, otherwise None.

Examples found in repository?
examples/main.rs (line 31)
5fn main() {
6    // 1. Create a new Issues collection
7    let mut issues = Issues::new();
8    println!("Initial issues count: {}", issues.get_list().len());
9
10    // 2. Create a User
11    let user = User::new("Alice", "alice@example.com");
12
13    // 3. Create a new Issue
14    let mut new_issue = Issue::new("Add better documentation", user.clone(), vec!["Enhance"]);
15
16    // 4. Add a Comment to the issue
17    let comment = Comment::new("I think we should add more examples.", user.clone());
18    new_issue.comment(comment);
19
20    // 5. Add the issue to the collection
21    let issue_index = issues.add_new_issue(new_issue);
22    println!("Added new issue at index: {}", issue_index);
23
24    // 6. Print all issues
25    println!("\nAll Issues:");
26    for (i, issue) in issues.get_list().iter().enumerate() {
27        println!("Issue #{}: {:?}", i, issue);
28    }
29
30    // 7. Find an issue by title
31    if let Some(found_issues) = issues.find_from_title("documentation") {
32        println!(
33            "\nFound {} issues matching 'documentation'",
34            found_issues.len()
35        );
36    }
37
38    // 8. Fork an issue
39    if let Some(forked_index) = issues.fork(1) {
40        println!("\nForked issue #1 to new issue #{}", forked_index);
41        let forked_issue = issues.get(forked_index).unwrap();
42        println!("Forked issue details: {:?}", forked_issue);
43
44        let original_issue = issues.get(1).unwrap();
45        println!("Original issue status after fork: {:?}", original_issue);
46    }
47}
Source

pub fn find_from_updated_time( &mut self, st: DateTime<Local>, ed: DateTime<Local>, ) -> Option<Vec<&mut Issue>>

Finds issues updated within the given time range.

Returns Some(Vec<&mut Issue>) if matches are found, otherwise None.

Source

pub fn find_from_created_time( &mut self, st: DateTime<Local>, ed: DateTime<Local>, ) -> Option<Vec<&mut Issue>>

Finds issues created within the given time range.

Returns Some(Vec<&mut Issue>) if matches are found, otherwise None.

Source

pub fn find_from_comments<T: AsRef<str>>( &mut self, s: T, ) -> Option<Vec<&mut Issue>>

Finds issues containing a comment with the given text.

Returns Some(Vec<&mut Issue>) if matches are found, otherwise None.

Source

pub fn get(&self, index: usize) -> Option<&Issue>

Gets an issue by its index.

Examples found in repository?
examples/main.rs (line 41)
5fn main() {
6    // 1. Create a new Issues collection
7    let mut issues = Issues::new();
8    println!("Initial issues count: {}", issues.get_list().len());
9
10    // 2. Create a User
11    let user = User::new("Alice", "alice@example.com");
12
13    // 3. Create a new Issue
14    let mut new_issue = Issue::new("Add better documentation", user.clone(), vec!["Enhance"]);
15
16    // 4. Add a Comment to the issue
17    let comment = Comment::new("I think we should add more examples.", user.clone());
18    new_issue.comment(comment);
19
20    // 5. Add the issue to the collection
21    let issue_index = issues.add_new_issue(new_issue);
22    println!("Added new issue at index: {}", issue_index);
23
24    // 6. Print all issues
25    println!("\nAll Issues:");
26    for (i, issue) in issues.get_list().iter().enumerate() {
27        println!("Issue #{}: {:?}", i, issue);
28    }
29
30    // 7. Find an issue by title
31    if let Some(found_issues) = issues.find_from_title("documentation") {
32        println!(
33            "\nFound {} issues matching 'documentation'",
34            found_issues.len()
35        );
36    }
37
38    // 8. Fork an issue
39    if let Some(forked_index) = issues.fork(1) {
40        println!("\nForked issue #1 to new issue #{}", forked_index);
41        let forked_issue = issues.get(forked_index).unwrap();
42        println!("Forked issue details: {:?}", forked_issue);
43
44        let original_issue = issues.get(1).unwrap();
45        println!("Original issue status after fork: {:?}", original_issue);
46    }
47}
Source

pub fn get_mut(&mut self, index: usize) -> Option<&mut Issue>

Gets a mutable reference to an issue by its index.

Source

pub fn fork(&mut self, from: usize) -> Option<usize>

Forks an issue from a given index.

The original issue is marked as CloseAsForked, and a new copy is created with from set to the original index.

Returns Some(usize) which is the index of the new forked issue, or None if the original issue doesn’t exist.

Examples found in repository?
examples/main.rs (line 39)
5fn main() {
6    // 1. Create a new Issues collection
7    let mut issues = Issues::new();
8    println!("Initial issues count: {}", issues.get_list().len());
9
10    // 2. Create a User
11    let user = User::new("Alice", "alice@example.com");
12
13    // 3. Create a new Issue
14    let mut new_issue = Issue::new("Add better documentation", user.clone(), vec!["Enhance"]);
15
16    // 4. Add a Comment to the issue
17    let comment = Comment::new("I think we should add more examples.", user.clone());
18    new_issue.comment(comment);
19
20    // 5. Add the issue to the collection
21    let issue_index = issues.add_new_issue(new_issue);
22    println!("Added new issue at index: {}", issue_index);
23
24    // 6. Print all issues
25    println!("\nAll Issues:");
26    for (i, issue) in issues.get_list().iter().enumerate() {
27        println!("Issue #{}: {:?}", i, issue);
28    }
29
30    // 7. Find an issue by title
31    if let Some(found_issues) = issues.find_from_title("documentation") {
32        println!(
33            "\nFound {} issues matching 'documentation'",
34            found_issues.len()
35        );
36    }
37
38    // 8. Fork an issue
39    if let Some(forked_index) = issues.fork(1) {
40        println!("\nForked issue #1 to new issue #{}", forked_index);
41        let forked_issue = issues.get(forked_index).unwrap();
42        println!("Forked issue details: {:?}", forked_issue);
43
44        let original_issue = issues.get(1).unwrap();
45        println!("Original issue status after fork: {:?}", original_issue);
46    }
47}
Source

pub fn get_registered_labels(&self) -> Vec<String>

Returns a list of all registered labels.

Trait Implementations§

Source§

impl Clone for Issues

Source§

fn clone(&self) -> Issues

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Issues

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Issues

Source§

fn default() -> Issues

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Issues

Source§

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 Serialize for Issues

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Storeable for Issues

Source§

fn save<P>( &self, path: P, new_create: bool, format: Format, ) -> Result<(), Error>
where P: AsRef<Path>,

Save to file. Read more
Source§

fn save_by_extension<P>(&self, path: P, new_create: bool) -> Result<(), Error>
where P: AsRef<Path>,

save to file by extension of path Read more
Source§

fn load<P>(path: P, format: Format) -> Result<Self, Error>
where P: AsRef<Path>,

Load from file. Read more
Source§

fn load_by_extension<P>(path: P) -> Result<Self, Error>
where P: AsRef<Path>,

load from file by extension of path Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.