Simplify enum objects #39
No reviewers
Labels
No labels
Automated
Backlog
Post_Prototype_1.0
Bot_Code
Core
Bot_Code
Custom
CI/CD
Complexity
Advanced
Complexity
Basic
Complexity
Expert
Complexity
Intermediate
Kind/Breaking
Kind/Bug
Kind/Bug Fix
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Nix
Ownership
Collab
Ownership
Collab with Leads
Ownership
Individual Lead
Ownership
In-Review
Ownership
Needs Owner > May Delegate
Ownership
Workshop with Leads
Phase 1.0
Requirements > Drafting
Phase 1.0
Requirements > Researching
Phase 1.0
Requirements > Review & Planning
Phase 2.0
Design > Research & Analysis
Phase 3.0
Coding > Implementation
Phase 4.0
QA > Unit Testing & Design
Phase 5.0
Resolution > Completed
Phase 5.0
Resolution > Review for Completion
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: modulatingforce/forcebot_rs#39
Loading…
Reference in a new issue
No description provided.
Delete branch "Simplify-objects"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Below example problem code
We can probably have that simplified to
I believe there was some reason I chose the enum path? But we'll document any issues here
This change will :
improve readability of code
ModType
have no meaning if it's only variant isBotModules
not improve or optimize code
Plan of Action :
BotModule
to tuple structs (similar to above)Related documentation
Using Tuple Structs Without Named Fields to Create Different Types
https://doc.rust-lang.org/book/ch05-01-defining-structs.html#using-tuple-structs-without-named-fields-to-create-different-types
I tried my best 👍 I've runned the bot a couple times after the updates and it seens to be working, but Idk what other tests might be needed to fully see if everything works fine, also, there is a part in the code that can be further edited, in identity.rs line 590
pub struct IdentityManager { special_roles_users: Arc<RwLock<UserRolesDB>>, }
can be changed to
pub struct IdentityManager(Arc<RwLock<UserRolesDB>>);
but I don't know how to change the rest of the code to adjust to this change 😢
Also, I hope I didn't break everything Lule
Hi @HaruYuumei
Great work! I still need to checkout the code for any other areas, but this is exactly what I was looking for
Could you look though on these two comments? Can it be set this way or were there issues setting it this way?
Thanks!
@ -34,0 +34,4 @@
// pub use ChType::Channel;
//
//simplifying from enum to struct
pub struct Channel(pub String);
Does this work instead? I don't know if
pub
is required next toString
Preferring Haru's original (below) as this would allow a more intuitive use of this simple structure
@ -47,0 +45,4 @@
// BotModule(String),
// }
pub struct BotModule(pub String);
Does this work instead? I don't know if
pub
is required next toString
Preferring Haru's original (below) as this would allow a more intuitive use of this simple structure
Oh to add, uhh Yeah I think some of the other more complex structs could have the same ideas applies, but I'm going to hold off for now just in case.
IdentityManager
for example, I'm not sure just yet if I'm just sticking with that one attribute or notSo for the complex ones, we'll hold off for now
👍yeah no other areas of improvement. I thought there was more
enum
andstruct
than I originally thoughtIf the comments from #39 (comment) can be addressed first, we can likely go ahead with the merge
Looking good @HaruYuumei ! I've set this to
Need More Info
in case you have any questions or want to review before we merge and delete the branchIf ready to merge, remove the WIP flag, and we'll merge it in
Looks like its working fine for now :) I think it can be merged 👍
WIP: Simplify enum objectsto Review: Simplify enum objects333bd34866
to503910b252
Review: Simplify enum objectsto Simplify enum objectsf49b4da0c5
to503910b252
503910b252
to3a0e00c323