11#![ allow( clippy:: needless_collect) ]
2- /// ! Session
2+ //! Session
33use crate :: autocomplete:: FileCompleter ;
44use crate :: brush:: * ;
55use crate :: cmd:: { self , Command , CommandLine , KeyMapping , Op , Value } ;
@@ -68,9 +68,10 @@ pub type SessionCoords = Point<Session, f32>;
6868
6969/// An editing mode the `Session` can be in.
7070/// Some of these modes are inspired by vi.
71- #[ derive( Eq , PartialEq , Copy , Clone , Debug ) ]
71+ #[ derive( Eq , PartialEq , Copy , Clone , Debug , Default ) ]
7272pub enum Mode {
7373 /// Allows the user to paint pixels.
74+ #[ default]
7475 Normal ,
7576 /// Allows pixels to be selected, copied and manipulated visually.
7677 Visual ( VisualState ) ,
@@ -83,12 +84,6 @@ pub enum Mode {
8384 Help ,
8485}
8586
86- impl Default for Mode {
87- fn default ( ) -> Self {
88- Mode :: Normal
89- }
90- }
91-
9287impl fmt:: Display for Mode {
9388 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
9489 match self {
@@ -227,9 +222,10 @@ pub enum State {
227222}
228223
229224/// An editing tool.
230- #[ derive( PartialEq , Eq , Debug , Clone ) ]
225+ #[ derive( PartialEq , Eq , Debug , Clone , Default ) ]
231226pub enum Tool {
232227 /// The standard drawing tool.
228+ #[ default]
233229 Brush ,
234230 /// Used for filling enclosed regions with color.
235231 FloodFill ,
@@ -239,12 +235,6 @@ pub enum Tool {
239235 Pan ( PanState ) ,
240236}
241237
242- impl Default for Tool {
243- fn default ( ) -> Self {
244- Tool :: Brush
245- }
246- }
247-
248238#[ derive( PartialEq , Eq , Debug , Clone , Copy ) ]
249239pub enum PanState {
250240 Panning ,
@@ -1545,10 +1535,10 @@ impl Session {
15451535 let view = self . view ( id) ;
15461536 let delay = time:: Duration :: from_millis ( self . settings [ "animation/delay" ] . to_u64 ( ) ) ;
15471537
1548- view. save_gif ( & path, delay, & palette, scale) ?
1538+ view. save_gif ( path, delay, & palette, scale) ?
15491539 }
1550- "svg" => self . view ( id) . save_svg ( & path, scale) ?,
1551- "png" => self . view ( id) . save_png ( & path, scale) ?,
1540+ "svg" => self . view ( id) . save_svg ( path, scale) ?,
1541+ "png" => self . view ( id) . save_png ( path, scale) ?,
15521542 _ => {
15531543 return Err ( io:: Error :: new (
15541544 io:: ErrorKind :: InvalidInput ,
@@ -2190,7 +2180,7 @@ impl Session {
21902180 let path = path. as_ref ( ) ;
21912181 debug ! ( "source: {}" , path. display( ) ) ;
21922182
2193- File :: open ( & path)
2183+ File :: open ( path)
21942184 . or_else ( |_| File :: open ( self . proj_dirs . config_dir ( ) . join ( path) ) )
21952185 . and_then ( |f| self . source_reader ( io:: BufReader :: new ( f) , path) )
21962186 . map_err ( |e| {
@@ -2678,7 +2668,6 @@ impl Session {
26782668 }
26792669 }
26802670 }
2681- #[ allow( mutable_borrow_reservation_conflict) ]
26822671 Command :: Toggle ( ref k) => match self . settings . get ( k) {
26832672 Some ( Value :: Bool ( b) ) => self . command ( Command :: Set ( k. clone ( ) , Value :: Bool ( !b) ) ) ,
26842673 Some ( _) => {
0 commit comments