pub struct Issues { /* private fields */ }Expand description
A collection of issues.
Implementations§
Source§impl Issues
impl Issues
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new Issues collection.
This initializes the collection with a “root” issue.
Examples found in repository?
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}Sourcepub fn add_new_issue(&mut self, i: Issue) -> usize
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?
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}Sourcepub fn get_list(&self) -> &Vec<Issue>
pub fn get_list(&self) -> &Vec<Issue>
Returns a reference to the list of issues.
Examples found in repository?
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}Sourcepub fn find_from_title<T: AsRef<str>>(
&mut self,
s: T,
) -> Option<Vec<&mut Issue>>
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?
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}Sourcepub fn find_from_updated_time(
&mut self,
st: DateTime<Local>,
ed: DateTime<Local>,
) -> Option<Vec<&mut Issue>>
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.
Sourcepub fn find_from_created_time(
&mut self,
st: DateTime<Local>,
ed: DateTime<Local>,
) -> Option<Vec<&mut Issue>>
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.
Sourcepub fn find_from_comments<T: AsRef<str>>(
&mut self,
s: T,
) -> Option<Vec<&mut Issue>>
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.
Sourcepub fn get(&self, index: usize) -> Option<&Issue>
pub fn get(&self, index: usize) -> Option<&Issue>
Gets an issue by its index.
Examples found in repository?
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}Sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut Issue>
pub fn get_mut(&mut self, index: usize) -> Option<&mut Issue>
Gets a mutable reference to an issue by its index.
Sourcepub fn fork(&mut self, from: usize) -> Option<usize>
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?
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}Sourcepub fn get_registered_labels(&self) -> Vec<String>
pub fn get_registered_labels(&self) -> Vec<String>
Returns a list of all registered labels.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Issues
impl<'de> Deserialize<'de> for Issues
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>,
Source§impl Storeable for Issues
impl Storeable for Issues
Source§fn save<P>(
&self,
path: P,
new_create: bool,
format: Format,
) -> Result<(), Error>
fn save<P>( &self, path: P, new_create: bool, format: Format, ) -> Result<(), Error>
Source§fn save_by_extension<P>(&self, path: P, new_create: bool) -> Result<(), Error>
fn save_by_extension<P>(&self, path: P, new_create: bool) -> Result<(), Error>
path Read more