snaplog 0.4.0

A library for easily recording changes to values
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
//! A scoped [`ScopedSnaplog`][Snaplog] and it's associated types. A `ScopedSnaplog` is used to
//! record snapshots of changes to only part of a value, such as successive edits to a file's name
//! without editing it's ancestors.
//!
//! To scope a type, implement [`IntoScoped`], a trait to denote how to deconstruct and reconstruct
//! the type, the `ScopedSnaplog` takes care of the rest.
//!
//! # Examples
//! All examples in this module assume this type is given.
//!
//! Given a type like this:
//! ```
//! use snaplog::scoped::IntoScoped;
//!
//! #[derive(Debug, PartialEq)]
//! pub struct Prefixed {
//!     pub prefix: Option<&'static str>,
//!     pub content: &'static str,
//! }
//!
//! impl Prefixed {
//!     pub fn new(s: &'static str) -> Self {
//!         let parts = s.split_once(':');
//!
//!         Self {
//!             prefix: parts.map(|(p, _)| p),
//!             content: parts.map(|(_, c)| c).unwrap_or(s),
//!         }
//!     }
//! }
//!
//! impl IntoScoped for Prefixed {
//!     type Scope = &'static str;
//!     type Ignored = Option<&'static str>;
//!
//!     fn into_scoped(self) -> (Self::Scope, Self::Ignored) {
//!         (self.content, self.prefix)
//!     }
//!
//!     fn from_scoped(scope: Self::Scope, ignored: Self::Ignored) -> Self {
//!         Self {
//!             prefix: ignored,
//!             content: scope,
//!         }
//!     }
//! }
//! ```
//!
//! You can use the [`Snaplog`] like this:
//! ```
//! # use snaplog::{Select, scoped::{Snaplog, __Prefixed as Prefixed}};
//! let mut snaplog = Snaplog::new(Prefixed::new("prefix:content"));
//! assert_eq!(snaplog.has_changes(), false);
//!
//! snaplog.record_change(|prev| { assert_eq!(prev, &"content"); "content-copy" });
//! snaplog.record_change(|prev| { assert_eq!(prev, &"content-copy"); "new" });
//! assert_eq!(snaplog.has_changes(), true);
//!
//! assert_eq!(snaplog[Select::Initial], "content");
//! assert_eq!(snaplog[Select::At(1)],   "content-copy");
//! assert_eq!(snaplog[Select::Current], "new");
//!
//! snaplog.clear_history();
//!
//! assert_eq!(snaplog.history(), ["new"]);
//! assert_eq!(snaplog.has_changes(), false);
//! # Ok::<_, Box<dyn std::error::Error>>(())
//! ```
//!
//! And when all changes are done you can simply recombine the parts:
//! ```
//! # use snaplog::{Select, scoped::{Snaplog, __Prefixed as Prefixed}};
//! # let mut snaplog = Snaplog::new(Prefixed::new("prefix:content"));
//! # snaplog.record("content-copy");
//! # snaplog.record("new");
//! assert_eq!(snaplog.into_current(), Prefixed::new("prefix:new"));
//! ```

use crate::full;
use crate::{EmptyHistoryError, Select};

use std::collections::TryReserveError;
use std::ops::RangeBounds;

mod docs_impl;

#[doc(hidden)]
pub use docs_impl::__Prefixed;

/// A trait for types that can be scoped into parts to apply changes only partially. See
/// [`ScopedSnaplog`][Snaplog] for examples.
pub trait IntoScoped {
    /// The type of the scope that is used when applying changes.
    type Scope;

    /// The type of the part that is ignored when applying changes.
    type Ignored;

    /// Separates `Self` into it's scoped and ignored part.
    fn into_scoped(self) -> (Self::Scope, Self::Ignored);

    /// Creates `Self` from it's scope and ignored part.
    fn from_scoped(scope: Self::Scope, ignored: Self::Ignored) -> Self;
}

/// A trait for [`T: IntoScoped`][IntoScoped] that can create thin immutable reference wrappers from
/// references to their parts which behave like a reference to `Self`.
///
/// This trait has correctness requirements similar to [`Borrow`][0], if a trait like [`Eq`],
/// [`Ord`] or [`Hash`] is implemented for `T`, then the same conditions formulated by `Borrow` must
/// hold.
///
/// [0]: std::borrow::Borrow
pub trait AsThinScoped: IntoScoped {
    /// An immutable thin reference type that behaves like `&Self`.
    type ThinScoped<'this>;

    /// Creates [`Self::ThinScoped`] from references to it's scope and ignored part.
    fn as_thin_scoped<'a>(
        scope: &'a Self::Scope,
        ignored: &'a Self::Ignored,
    ) -> Self::ThinScoped<'a>;
}

/// A trait for [`T: IntoScoped`][IntoScoped] that can create thin mutable reference wrappers from
/// mutable references to their parts which behave like a reference to `Self`.
///
/// This trait has correctness requirements similar to [`BorrowMut`][0], if a trait like [`Eq`],
/// [`Ord`] or [`Hash`] is implemented for `T`, then the same conditions formulated by `BorrowMut`
/// must hold.
///
/// [0]: std::borrow::BorrowMut
pub trait AsThinScopedMut: AsThinScoped {
    /// A mutable thin reference type that behaves like `&mut Self`.
    type ThinScopedMut<'this>;

    /// Creates [`Self::ThinScopedMut`] from mutable references to it's scope and ignored part.
    fn as_thin_scoped_mut<'a>(
        scope: &'a mut Self::Scope,
        ignored: &'a mut Self::Ignored,
    ) -> Self::ThinScopedMut<'a>;
}

/// A [`Snaplog`][full] that is scoped to only part of of a type.
///
/// # Examples
/// ```
/// # use snaplog::{Select, scoped::{Snaplog, __Prefixed as Prefixed}};
/// let mut snaplog = Snaplog::new(Prefixed::new("prefix:content"));
/// assert_eq!(snaplog.has_changes(), false);
///
/// snaplog.record_change(|prev| { assert_eq!(prev, &"content"); "content-copy" });
/// snaplog.record_change(|prev| { assert_eq!(prev, &"content-copy"); "new" });
/// assert_eq!(snaplog.has_changes(), true);
///
/// assert_eq!(snaplog[Select::Initial], "content");
/// assert_eq!(snaplog[Select::At(1)],   "content-copy");
/// assert_eq!(snaplog[Select::Current], "new");
///
/// snaplog.clear_history();
///
/// assert_eq!(snaplog.history(), ["new"]);
/// assert_eq!(snaplog.has_changes(), false);
/// # Ok::<_, Box<dyn std::error::Error>>(())
/// ```
///
/// [full]: full::Snaplog
#[derive(Debug, PartialEq, Eq)]
pub struct Snaplog<T: IntoScoped> {
    full: full::Snaplog<T::Scope>,
    ignored: T::Ignored,
}

/// Various constructor functions.
impl<T: IntoScoped> Snaplog<T> {
    /// Creates a new [`Snaplog`] from the given `initial` snapshot with no recorded changes.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let snaplog = Snaplog::new(Prefixed::new("prefix:content"));
    ///
    /// assert_eq!(snaplog.initial(), &"content");
    /// assert_eq!(snaplog.ignored(), &Some("prefix"));
    /// assert_eq!(snaplog.has_changes(), false);
    /// ```
    pub fn new(initial: T) -> Self {
        let (scope, ignored) = initial.into_scoped();

        Self {
            full: full::Snaplog::new(scope),
            ignored,
        }
    }

    /// Creates a new [`Snaplog`] for the given `history` backing vector.
    ///
    /// # Errors
    /// Returns an error if `history` was empty.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// assert!(Snaplog::<Prefixed>::try_from_vec(vec!["content"], None).is_ok());
    /// assert!(Snaplog::<Prefixed>::try_from_vec(vec![], Some("prefix")).is_err());
    /// ```
    pub fn try_from_vec(
        history: Vec<T::Scope>,
        ignored: T::Ignored,
    ) -> Result<Self, EmptyHistoryError> {
        Ok(Self {
            full: full::Snaplog::try_from_vec(history)?,
            ignored,
        })
    }

    /// Creates a new [`Snaplog`] for the given `history` backing vector.
    ///
    /// # Panics
    /// Panics if `history` was empty.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let snaplog: Snaplog<Prefixed> = Snaplog::from_vec(vec![""], None);
    /// ```
    ///
    /// This panics:
    /// ```should_panic
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let snaplog: Snaplog<Prefixed> = Snaplog::from_vec(vec![], Some("Prefix"));
    /// ```
    pub fn from_vec(history: Vec<T::Scope>, ignored: T::Ignored) -> Self {
        match Self::try_from_vec(history, ignored) {
            Ok(this) => this,
            Err(_) => panic!("history must not be empty"),
        }
    }

    /// Creates a new [`Snaplog`] from the given `history`. The elements are collected into a
    /// [`Vec`] the if you already have a vec at hand use [`from_vec`][Self::try_from_vec]. The
    /// first element is used as the initial element.
    ///
    /// # Errors
    /// Returns an error if `history` was empty.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// assert!(Snaplog::<Prefixed>::try_from_history(["a", "b", "c"], None).is_ok());
    /// assert!(Snaplog::<Prefixed>::try_from_history(std::iter::empty(), Some("a")).is_err());
    /// ```
    pub fn try_from_history<I>(history: I, ignored: T::Ignored) -> Result<Self, EmptyHistoryError>
    where
        I: IntoIterator<Item = T::Scope>,
    {
        Self::try_from_vec(history.into_iter().collect(), ignored)
    }

    /// Creates a new [`Snaplog`] from the given `history`. The elements are collected into a
    /// [`Vec`] the if you already have a vec at hand use [`from_vec`][Self::from_vec]. The first
    /// element is used as the initial element.
    ///
    /// # Panics
    /// Panics if `history` was empty.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let snaplog: Snaplog<Prefixed> = Snaplog::from_history(["a", "b", "c"], None);
    /// ```
    ///
    /// This panics:
    /// ```should_panic
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let snaplog: Snaplog<Prefixed> = Snaplog::from_history(std::iter::empty(), Some("prefix"));
    /// ```
    pub fn from_history<I>(history: I, ignored: T::Ignored) -> Self
    where
        I: IntoIterator<Item = T::Scope>,
    {
        Self::from_vec(history.into_iter().collect(), ignored)
    }
}

/// First class [`Snaplog`] members.
impl<T: IntoScoped> Snaplog<T> {
    /// Returns a reference to the internal [`Snaplog`].
    ///
    /// # Examples
    /// ```
    /// # use snaplog::{full, scoped::{Snaplog, __Prefixed as Prefixed}};
    /// let snaplog = Snaplog::new(Prefixed::new("prefix:content"));
    ///
    /// assert_eq!(snaplog.scope(), &full::Snaplog::new("content"));
    /// ```
    pub fn scope(&self) -> &full::Snaplog<T::Scope> {
        &self.full
    }

    /// Returns a mutable reference to the internal [`full::Snaplog`].
    ///
    /// # Examples
    /// ```
    /// # use snaplog::{full, scoped::{Snaplog, __Prefixed as Prefixed}};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:content"));
    ///
    /// assert_eq!(snaplog.scope(), &mut full::Snaplog::new("content"));
    /// ```
    pub fn scope_mut(&mut self) -> &mut full::Snaplog<T::Scope> {
        &mut self.full
    }

    /// Returns a reference to the ignored part of this [`Snaplog`].
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let snaplog = Snaplog::new(Prefixed::new("prefix:content"));
    ///
    /// assert_eq!(snaplog.ignored(), &Some("prefix"));
    /// ```
    pub fn ignored(&self) -> &T::Ignored {
        &self.ignored
    }

    /// Returns a mutable reference to the internal [`full::Snaplog`].
    ///
    /// # Examples
    /// ```
    /// # use snaplog::{full, scoped::{Snaplog, __Prefixed as Prefixed}};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:content"));
    ///
    /// assert_eq!(snaplog.into_scope(), full::Snaplog::new("content"));
    /// ```
    pub fn into_scope(self) -> full::Snaplog<T::Scope> {
        self.full
    }
}

/// Implementations similar to [`full::Snaplog`].
impl<T: IntoScoped> Snaplog<T> {
    /// Records a snapshot in this [`Snaplog`].
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// assert_eq!(snaplog.history(), ["a", "b", "c"]);
    /// ```
    pub fn record(&mut self, snapshot: T::Scope) {
        self.full.record(snapshot);
    }

    /// Records multiple snapshots in this [`Snaplog`].
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record_all(["b", "c", "d"]);
    /// assert_eq!(snaplog.history(), ["a", "b", "c", "d"]);
    /// ```
    pub fn record_all<I>(&mut self, snapshots: I)
    where
        I: IntoIterator<Item = T::Scope>,
    {
        self.full.record_all(snapshots);
    }

    /// Records a change to the current element in this [`Snaplog`].
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record_change(|prev| { assert_eq!(prev, &"a"); "b" });
    /// snaplog.record_change(|prev| { assert_eq!(prev, &"b"); "c" });
    /// assert_eq!(snaplog.history(), ["a", "b", "c"]);
    /// ```
    pub fn record_change<F>(&mut self, f: F)
    where
        F: FnMut(&T::Scope) -> T::Scope,
    {
        self.full.record_change(f)
    }

    /// Records a change to the current element in this [`Snaplog`].
    ///
    /// # Errors
    /// Returns the inner error if the closure failed.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.try_record_change(|prev| { assert_eq!(prev, &"a"); Ok("b") })?;
    /// snaplog.try_record_change(|prev| { assert_eq!(prev, &"b"); Ok("c") })?;
    /// assert_eq!(snaplog.try_record_change(|prev| Err(())), Err(()));
    /// assert_eq!(snaplog.history(), ["a", "b", "c"]);
    /// # Ok::<_, ()>(())
    /// ```
    pub fn try_record_change<F, E>(&mut self, f: F) -> Result<(), E>
    where
        F: FnMut(&T::Scope) -> Result<T::Scope, E>,
    {
        self.full.try_record_change(f)
    }

    /// Records multiple successive changes to the current element in this [`Snaplog`].
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record_changes_all(&mut ["b", "c", "d"], |change, _| *change);
    /// assert_eq!(snaplog.history(), ["a", "b", "c", "d"]);
    /// ```
    pub fn record_changes_all<F, M>(&mut self, mutations: &mut [M], f: F)
    where
        F: FnMut(&mut M, &T::Scope) -> T::Scope,
    {
        self.full.record_changes_all(mutations, f);
    }

    /// Returns whether or not there are any changes recorded in this [`Snaplog`].
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// assert_eq!(snaplog.has_changes(), false);
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// assert_eq!(snaplog.has_changes(), true);
    /// ```
    pub fn has_changes(&self) -> bool {
        self.full.has_changes()
    }

    /// Returns the initial element.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// assert_eq!(snaplog.initial(), &"a");
    /// ```
    pub fn initial(&self) -> &T::Scope {
        self.full.initial()
    }

    /// Returns the element at the given [`Select`].
    ///
    /// # Examples
    /// ```
    /// # use snaplog::{Select, scoped::{Snaplog, __Prefixed as Prefixed}};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// assert_eq!(snaplog.snapshot_at(Select::At(1)), &"b");
    /// ```
    pub fn snapshot_at(&self, select: Select) -> &T::Scope {
        self.full.snapshot_at(select)
    }

    /// Returns the current element, that is the last recorded change or the initial element if
    /// there are no none.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// assert_eq!(snaplog.current(), &"c");
    /// ```
    pub fn current(&self) -> &T::Scope {
        self.full.current()
    }

    /// Returns the initial element.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// assert_eq!(snaplog.initial_mut(), &mut "a");
    /// ```
    pub fn initial_mut(&mut self) -> &mut T::Scope {
        self.full.initial_mut()
    }

    /// Returns the element at the given [`Select`].
    ///
    /// # Examples
    /// ```
    /// # use snaplog::{Select, scoped::{Snaplog, __Prefixed as Prefixed}};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// assert_eq!(snaplog.snapshot_at_mut(Select::At(1)), &mut "b");
    /// ```
    pub fn snapshot_at_mut(&mut self, select: Select) -> &mut T::Scope {
        self.full.snapshot_at_mut(select)
    }

    /// Returns the current element, that is the last recorded change or the initial element if
    /// there are no none.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// assert_eq!(snaplog.current_mut(), &mut "c");
    /// ```
    pub fn current_mut(&mut self) -> &mut T::Scope {
        self.full.current_mut()
    }

    /// Clones the element at the given [`Select`].
    ///
    /// # Examples
    /// ```
    /// # use snaplog::{scoped::{Snaplog, __Prefixed as Prefixed}, Select};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// assert_eq!(snaplog.clone_snapshot_at(Select::At(1)), Prefixed::new("prefix:b"));
    /// ```
    pub fn clone_snapshot_at(&self, select: Select) -> T
    where
        T::Scope: Clone,
        T::Ignored: Clone,
    {
        // TODO: let the user decide how to reconstruct from references? breaks IntoScoped interface
        T::from_scoped(self.snapshot_at(select).clone(), self.ignored.clone())
    }

    /// Returns the full history recorded in this [`Snaplog`], including the initial element.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// assert_eq!(snaplog.history(), ["a", "b", "c"]);
    /// ```
    pub fn history(&self) -> &[T::Scope] {
        self.full.history()
    }

    /// Returns a mutable reference to the underlying `history`.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog: Snaplog<Prefixed> = Snaplog::try_from_history(
    ///     ["a", "b", "c", "d", "e"],
    ///     None,
    /// )?;
    /// let history = snaplog.history_mut();
    ///
    /// history[0] = "g";
    /// assert_eq!(snaplog.history(), ["g", "b", "c", "d", "e"]);
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// ```
    pub fn history_mut(&mut self) -> &mut [T::Scope] {
        self.full.history_mut()
    }

    /// Drains the history in the specified range, a left open range is interpreted as starting
    /// behind the initial element, elements that are not yielded from the [`Iterator`] are dropped.
    ///
    /// # Panics
    /// Panics if the lower range bound is inclusive `0`.
    /// Panics if the lower or upper bound are out of range.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog: Snaplog<Prefixed> = Snaplog::try_from_history(
    ///     ["a", "b", "c", "d", "e"],
    ///     None,
    /// )?;
    ///
    /// snaplog.drain(2..=3);
    /// assert_eq!(snaplog.history(), ["a", "b", "e"]);
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// ```
    /// The unbounded range is reinterpreted as starting at `1`:
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// # let mut snaplog: Snaplog<Prefixed> = Snaplog::try_from_history(["a", "b", "c", "d", "e"],
    /// # None)?;
    /// snaplog.drain(..);
    /// assert_eq!(snaplog.history(), ["a"]);
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// ```
    /// The only invalid lower bound is `0`:
    /// ```should_panic
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// # let mut snaplog: Snaplog<Prefixed> = Snaplog::try_from_history(["a", "b", "c", "d", "e"],
    /// # None)?;
    /// snaplog.drain(0..);
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// ```
    pub fn drain<'r, R>(&'r mut self, range: R) -> impl Iterator<Item = T::Scope> + 'r
    where
        R: RangeBounds<usize> + 'r,
    {
        self.full.drain(range)
    }

    /// Wipe the recorded history, keeping only the current element as the new initial element.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// snaplog.clear_history();
    /// assert_eq!(snaplog.initial(), &"c");
    /// assert_eq!(snaplog.has_changes(), false);
    /// ```
    pub fn clear_history(&mut self) {
        self.full.clear_history();
    }

    /// Wipe the recorded changes, keeping only the initial element.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// snaplog.reset();
    /// assert_eq!(snaplog.initial(), &"a");
    /// assert_eq!(snaplog.has_changes(), false);
    /// ```
    pub fn reset(&mut self) {
        self.full.reset();
    }

    /// Reserve space for `n` additional elements.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    /// snaplog.reserve(10);
    /// ```
    pub fn reserve(&mut self, n: usize) {
        self.full.reserve(n);
    }

    /// Reserve space for `n` additional elements.
    ///
    /// # Errors
    /// Returns an error if [`Vec::try_reserve`] failed.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    /// snaplog.try_reserve(10)?;
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// ```
    pub fn try_reserve(&mut self, n: usize) -> Result<(), TryReserveError> {
        self.full.try_reserve(n)
    }

    /// Returns an iterator over references of the whole underling history.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog: Snaplog<Prefixed> = Snaplog::try_from_history(
    ///     ["a", "b", "c", "d", "e"],
    ///     None,
    /// )?;
    ///
    /// let mut copy = vec![];
    /// for (snapshot, _) in snaplog.iter() {
    ///     copy.push(*snapshot);
    /// }
    ///
    /// assert_eq!(copy, ["a", "b", "c", "d", "e"]);
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// ```
    pub fn iter(&self) -> Iter<'_, T> {
        self.into_iter()
    }

    /// Returns an iterator over mutable references of the whole underling history.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog: Snaplog<Prefixed> = Snaplog::try_from_history(
    ///     ["a", "b", "c", "d", "e"],
    ///     None,
    /// )?;
    ///
    /// for (snapshot, _) in snaplog.iter_mut().filter(|&(&mut s, _)| s == "a" || s == "d") {
    ///     *snapshot = "f";
    /// }
    ///
    /// assert_eq!(snaplog.history(), ["f", "b", "c", "f", "e"]);
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// ```
    pub fn iter_mut(&mut self) -> IterMut<'_, T> {
        self.into_iter()
    }

    /// Unwrap the [`Snaplog`] into it's initial snapshot.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// assert_eq!(snaplog.into_initial(), Prefixed::new("prefix:a"));
    /// ```
    pub fn into_initial(self) -> T {
        T::from_scoped(self.full.into_initial(), self.ignored)
    }

    /// Unwrap the [`Snaplog`] into it's current snapshot.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// assert_eq!(snaplog.into_current(), Prefixed::new("prefix:c"));
    /// ```
    pub fn into_current(self) -> T {
        T::from_scoped(self.full.into_current(), self.ignored)
    }

    /// Unwrap the [`Snaplog`] into it's current snapshot.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::{Select, scoped::{Snaplog, __Prefixed as Prefixed}};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// assert_eq!(snaplog.into_snapshot_at(Select::At(1)), Prefixed::new("prefix:b"));
    /// ```
    pub fn into_snapshot_at(self, select: Select) -> T {
        T::from_scoped(self.full.into_snapshot_at(select), self.ignored)
    }

    /// Unwrap the [`Snaplog`] into it's history.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::{full, scoped::{Snaplog, __Prefixed as Prefixed}};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// assert_eq!(
    ///     snaplog.into_inner(),
    ///     (full::Snaplog::from_history(["a", "b", "c"]), Some("prefix"))
    /// );
    /// ```
    pub fn into_inner(self) -> (full::Snaplog<T::Scope>, T::Ignored) {
        (self.full, self.ignored)
    }
}

/// Thin implementations.
impl<T: IntoScoped> Snaplog<T> {
    /// Constructs a [`T::ThinScoped`][0] reference wrapper of the element at the given [`Select`].
    ///
    /// [0]: AsThinScoped::ThinScoped
    ///
    /// # Examples
    /// ```
    /// # use snaplog::{scoped::{Snaplog, __Prefixed as Prefixed}, Select};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// // note that the equality impl of T::ThinScoped and &T is given for this example
    /// assert_eq!(snaplog.thin_snapshot_at(Select::At(1)), &Prefixed::new("prefix:b"));
    /// ```
    pub fn thin_snapshot_at(&self, select: Select) -> T::ThinScoped<'_>
    where
        T: AsThinScoped,
    {
        T::as_thin_scoped(self.snapshot_at(select), &self.ignored)
    }

    /// Constructs a [`T::ThinScopedMut`][0] reference wrapper of the element at the given
    /// [`Select`].
    ///
    /// [0]: AsThinScopedMut::ThinScopedMut
    ///
    /// # Examples
    /// ```
    /// # use snaplog::{scoped::{Snaplog, __Prefixed as Prefixed}, Select};
    /// let mut snaplog = Snaplog::new(Prefixed::new("prefix:a"));
    ///
    /// snaplog.record("b");
    /// snaplog.record("c");
    /// // note that the equality impl of T::ThinScopedMut and &T is given for this example
    /// assert_eq!(snaplog.thin_snapshot_at_mut(Select::At(1)), &mut Prefixed::new("prefix:b"));
    /// ```
    pub fn thin_snapshot_at_mut(&mut self, select: Select) -> T::ThinScopedMut<'_>
    where
        T: AsThinScopedMut,
    {
        T::as_thin_scoped_mut(self.full.snapshot_at_mut(select), &mut self.ignored)
    }
}

/// Unsafe implementations.
impl<T: IntoScoped> Snaplog<T> {
    /// Creates a new [`Snaplog`] for the given `history` backing vector.
    ///
    /// # Safety
    /// The caller must ensure that the [`Vec`] contains at least one element.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// // this is fine
    /// let snaplog: Snaplog<Prefixed> = unsafe {
    ///     Snaplog::from_vec_unchecked(vec!["content"], None)
    /// };
    ///
    /// // this will later fail
    /// let snaplog: Snaplog<Prefixed> = unsafe {
    ///     Snaplog::from_vec_unchecked(vec![], Some("prefix"))
    /// };
    /// ```
    pub unsafe fn from_vec_unchecked(history: Vec<T::Scope>, ignored: T::Ignored) -> Self {
        Self {
            // SAFETY: invariants must be upheld by the caller
            full: unsafe { full::Snaplog::from_vec_unchecked(history) },
            ignored,
        }
    }

    /// Creates a new [`Snaplog`] for the given `history` backing vector.
    ///
    /// # Safety
    /// The caller must ensure that the `iter` contains at least one element.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// // this is fine
    /// let snaplog: Snaplog<Prefixed> = unsafe {
    ///     Snaplog::from_history_unchecked(["a", "b", "c"], None)
    /// };
    ///
    /// // this will later fail
    /// let snaplog: Snaplog<Prefixed> = unsafe {
    ///     Snaplog::from_history_unchecked(std::iter::empty(), Some("prefix"))
    /// };
    /// ```
    pub unsafe fn from_history_unchecked<I>(history: I, ignored: T::Ignored) -> Self
    where
        I: IntoIterator<Item = T::Scope>,
    {
        // SAFETY: invariants must be upheld by the caller
        unsafe { Self::from_vec_unchecked(history.into_iter().collect(), ignored) }
    }

    /// Returns a mutable reference to the underlying [`Vec`]. The first element of this vector is
    /// the initial element and is always set.
    ///
    /// # Safety
    /// The caller must ensure that the [`Vec`] retains at least one element after mutation, this
    /// element serves as the initial element.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog: Snaplog<Prefixed> = Snaplog::try_from_history(
    ///     ["a", "b", "c", "d", "e", "f", "g"],
    ///     None,
    /// )?;
    ///
    /// // SAFETY: no elements are removed
    /// let inner = unsafe { snaplog.history_mut_vec() };
    /// inner[5] = "h";
    /// inner[6] = "i";
    /// inner.drain(1..=3);
    /// inner.push("j");
    ///
    /// assert_eq!(snaplog.history(), ["a", "e", "h", "i", "j"]);
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// ```
    pub unsafe fn history_mut_vec(&mut self) -> &mut Vec<T::Scope> {
        // SAFETY: invariants must be upheld by the caller
        unsafe { self.full.history_mut_vec() }
    }

    /// Returns a mutable reference to the ignored part.
    ///
    /// # Safety
    /// There are no safety concerns in the current version but this is unsafe because mutation that
    /// changes things like Hashing may not be expected in other parts of the code, the caller must
    /// uphold invariants over the ignored part's mutation.
    ///
    /// # Examples
    /// ```
    /// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed};
    /// let mut snaplog: Snaplog<Prefixed> = Snaplog::try_from_history(
    ///     ["a", "b", "c", "d", "e"],
    ///     None,
    /// )?;
    ///
    /// // SAFETY: there are no invariants regarding Prefixed not having it's prefix mutated
    /// let inner = unsafe { snaplog.ignored_mut() };
    /// *inner = Some("new_prefix");
    ///
    /// assert_eq!(snaplog.into_current(), Prefixed::new("new_prefix:e"));
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// ```
    pub unsafe fn ignored_mut(&mut self) -> &mut T::Ignored {
        &mut self.ignored
    }
}

// first class traits
impl<T: IntoScoped> Clone for Snaplog<T>
where
    T::Scope: Clone,
    T::Ignored: Clone,
{
    fn clone(&self) -> Self {
        Self {
            full: self.full.clone(),
            ignored: self.ignored.clone(),
        }
    }

    fn clone_from(&mut self, source: &Self) {
        self.full.clone_from(&source.full);
        self.ignored.clone_from(&source.ignored);
    }
}

impl<T: IntoScoped> std::ops::Index<Select> for Snaplog<T> {
    type Output = T::Scope;

    fn index(&self, index: Select) -> &Self::Output {
        self.snapshot_at(index)
    }
}

impl<T: IntoScoped> std::ops::IndexMut<Select> for Snaplog<T> {
    fn index_mut(&mut self, index: Select) -> &mut Self::Output {
        self.snapshot_at_mut(index)
    }
}

// iter
impl<T: IntoScoped> std::iter::Extend<T::Scope> for Snaplog<T> {
    fn extend<I: IntoIterator<Item = T::Scope>>(&mut self, iter: I) {
        self.full.extend(iter);
    }
}

// iter
/// An [`Iterator`] over all snapshot scopes and references to the ignored part.
///
/// # Examples
/// ```
/// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed, IntoScoped};
/// # type Scope = &'static str;
/// # type Ignored = Option<&'static str>;
/// let mut snaplog = Snaplog::new(Prefixed::new("prefix:content"));
/// let mut iter = snaplog.into_iter();
///
/// for snapshot in iter {
///     let s: (Scope, Ignored) = snapshot;
/// }
///
/// let mut snaplog = Snaplog::new(Prefixed::new("prefix:content"));
///
/// for snapshot in snaplog {
///     let s: (Scope, Ignored) = snapshot;
/// }
/// ```
#[derive(Debug)]
pub struct IntoIter<T: IntoScoped> {
    inner: full::IntoIter<T::Scope>,
    ignored: T::Ignored,
}

impl<T: IntoScoped> IntoIter<T> {
    /// Returns a reference to the ignored part.
    pub fn ignored(&self) -> &T::Ignored {
        &self.ignored
    }
}

impl<T: IntoScoped> Iterator for IntoIter<T>
where
    T::Ignored: Clone,
{
    type Item = (T::Scope, T::Ignored);

    fn next(&mut self) -> Option<Self::Item> {
        // TODO: reduce last unnecessary clone by using a peeking iter and storing it as an Option
        self.inner.next().map(|s| (s, self.ignored.clone()))
    }
}

impl<T: IntoScoped> IntoIterator for Snaplog<T>
where
    T::Ignored: Clone,
{
    type Item = (T::Scope, T::Ignored);
    type IntoIter = IntoIter<T>;

    fn into_iter(self) -> Self::IntoIter {
        Self::IntoIter {
            inner: self.full.into_iter(),
            ignored: self.ignored,
        }
    }
}

// TODO: exact size iter etc

/// An [`Iterator`] over references to snapshot scopes and references to the ignored part.
///
/// # Examples
/// ```
/// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed, IntoScoped};
/// # type Scope = &'static str;
/// # type Ignored = Option<&'static str>;
/// let mut snaplog = Snaplog::new(Prefixed::new("prefix:content"));
///
/// for snapshot in snaplog.iter() {
///     let s: (&Scope, &Ignored) = snapshot;
/// }
///
/// for snapshot in &snaplog {
///     let s: (&Scope, &Ignored) = snapshot;
/// }
/// ```
#[derive(Debug)]
pub struct Iter<'cl, T: IntoScoped> {
    inner: full::Iter<'cl, T::Scope>,
    ignored: &'cl T::Ignored,
}

impl<'cl, T: IntoScoped> Iter<'cl, T> {
    /// Returns a reference to the ignored part.
    pub fn ignored(&self) -> &'cl T::Ignored {
        self.ignored
    }
}

impl<'cl, T: IntoScoped> Iterator for Iter<'cl, T> {
    type Item = (&'cl T::Scope, &'cl T::Ignored);

    fn next(&mut self) -> Option<Self::Item> {
        self.inner.next().map(|s| (s, self.ignored))
    }
}

impl<'cl, T: IntoScoped> IntoIterator for &'cl Snaplog<T> {
    type Item = (&'cl T::Scope, &'cl T::Ignored);
    type IntoIter = Iter<'cl, T>;

    fn into_iter(self) -> Self::IntoIter {
        Iter {
            inner: self.full.iter(),
            ignored: &self.ignored,
        }
    }
}

/// An [`Iterator`] over mutable references to snapshot scopes and references to the ignored part.
///
/// # Examples
/// ```
/// # use snaplog::scoped::{Snaplog, __Prefixed as Prefixed, IntoScoped};
/// # type Scope = &'static str;
/// # type Ignored = Option<&'static str>;
/// let mut snaplog = Snaplog::new(Prefixed::new("prefix:content"));
///
/// for snapshot in snaplog.iter_mut() {
///     let s: (&mut Scope, &Ignored) = snapshot;
/// }
///
/// for snapshot in &mut snaplog {
///     let s: (&mut Scope, &Ignored) = snapshot;
/// }
/// ```
#[derive(Debug)]
pub struct IterMut<'cl, T: IntoScoped> {
    inner: full::IterMut<'cl, T::Scope>,
    ignored: &'cl T::Ignored,
}

impl<'cl, T: IntoScoped> IterMut<'cl, T> {
    /// Returns a reference to the ignored part.
    pub fn ignored(&self) -> &'cl T::Ignored {
        self.ignored
    }
}

impl<'cl, T: IntoScoped> Iterator for IterMut<'cl, T> {
    type Item = (&'cl mut T::Scope, &'cl T::Ignored);

    fn next(&mut self) -> Option<Self::Item> {
        self.inner.next().map(|s| (s, self.ignored))
    }
}

impl<'cl, T: IntoScoped> IntoIterator for &'cl mut Snaplog<T> {
    type Item = (&'cl mut T::Scope, &'cl T::Ignored);
    type IntoIter = IterMut<'cl, T>;

    fn into_iter(self) -> Self::IntoIter {
        IterMut {
            inner: self.full.iter_mut(),
            ignored: &mut self.ignored,
        }
    }
}

// conversions
impl<T: IntoScoped> From<T> for Snaplog<T> {
    fn from(initial: T) -> Self {
        Self::new(initial)
    }
}

impl<T: IntoScoped> From<Snaplog<T>> for (full::Snaplog<T::Scope>, T::Ignored) {
    fn from(snaplog: Snaplog<T>) -> Self {
        snaplog.into_inner()
    }
}

impl<T: IntoScoped> TryFrom<(Vec<T::Scope>, T::Ignored)> for Snaplog<T> {
    type Error = EmptyHistoryError;

    fn try_from(value: (Vec<T::Scope>, T::Ignored)) -> Result<Self, Self::Error> {
        Self::try_from_vec(value.0, value.1)
    }
}