Skip to content

Commit d37f2d4

Browse files
committed
Rename Transmogrify to Cast and mog<T> to cast<T>.
Closes #221.
1 parent 3301995 commit d37f2d4

26 files changed

+1188
-1183
lines changed

subdoc/lib/gen/markdown_to_html.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ sus::Result<MarkdownToHtml, MarkdownToHtmlError> markdown_to_html(
344344
} else {
345345
// SAFETY: The input is a char, so tolower will give a value in the
346346
// range of char.
347-
c = sus::mog<char>(std::tolower(c));
347+
c = sus::cast<char>(std::tolower(c));
348348
}
349349
}
350350

sus/CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ target_sources(subspace PUBLIC
4545
"construct/into.h"
4646
"construct/default.h"
4747
"construct/safe_from_reference.h"
48-
"construct/transmogrify.h"
48+
"construct/cast.h"
4949
"collections/__private/slice_methods_impl.inc"
5050
"collections/__private/slice_methods.inc"
5151
"collections/__private/slice_mut_methods.inc"
@@ -171,7 +171,7 @@ target_sources(subspace PUBLIC
171171
"num/__private/unsigned_integer_consts.inc"
172172
"num/__private/unsigned_integer_methods.inc"
173173
"num/__private/unsigned_integer_methods_impl.inc"
174-
"num/transmogrify.h"
174+
"num/cast.h"
175175
"num/float.h"
176176
"num/float_concepts.h"
177177
"num/float_impl.h"
@@ -251,7 +251,7 @@ if(${SUBSPACE_BUILD_TESTS})
251251
"cmp/eq_unittest.cc"
252252
"cmp/ord_unittest.cc"
253253
"cmp/reverse_unittest.cc"
254-
"construct/transmogrify_unittest.cc"
254+
"construct/cast_unittest.cc"
255255
"collections/array_unittest.cc"
256256
"collections/compat_deque_unittest.cc"
257257
"collections/compat_forward_list_unittest.cc"
@@ -294,7 +294,7 @@ if(${SUBSPACE_BUILD_TESTS})
294294
"mem/take_unittest.cc"
295295
"num/__private/literals_unittest.cc"
296296
"num/cmath_macros_unittest.cc"
297-
"num/transmogrify_unittest.cc"
297+
"num/cast_unittest.cc"
298298
"num/f32_unittest.cc"
299299
"num/f64_unittest.cc"
300300
"num/i8_unittest.cc"

sus/boxed/dyn.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ namespace sus::boxed {
256256
/// In order to ensure the target of the `DynC&` reference outlives the function
257257
/// it can be constructed as a stack variable before calling the function.
258258
/// ```
259-
/// std::srand(sus::mog<unsigned>(std::time(nullptr)));
259+
/// std::srand(sus::cast<unsigned>(std::time(nullptr)));
260260
///
261261
/// auto x = [](sus::Option<sus::fn::DynFn<std::string()>&> fn) {
262262
/// if (fn.is_some())

sus/boxed/dyn_unittest.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ TEST(Dyn, Example_Macro) {
339339
} // namespace example_macro
340340

341341
TEST(Dyn, Example_Stack) {
342-
std::srand(sus::mog<unsigned>(std::time(nullptr)));
342+
std::srand(sus::cast<unsigned>(std::time(nullptr)));
343343

344344
auto x = [](sus::Option<sus::fn::DynFn<std::string()>&> fn) {
345345
if (fn.is_some())

sus/collections/array.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct Storage<T, 0> final {};
6969
/// subtracting a pointer at a greater distance results in Undefined Behaviour.
7070
template <class T, size_t N>
7171
class Array final {
72-
static_assert(N <= ::sus::mog<usize>(isize::MAX));
72+
static_assert(N <= ::sus::cast<usize>(isize::MAX));
7373
static_assert(!std::is_reference_v<T>,
7474
"Array<T&, N> is invalid as Array must hold value types. Use "
7575
"Array<T*, N> instead.");

sus/collections/slice.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
#include "sus/mem/clone.h"
4343
#include "sus/mem/move.h"
4444
#include "sus/mem/swap.h"
45+
#include "sus/num/cast.h"
4546
#include "sus/num/signed_integer.h"
46-
#include "sus/num/transmogrify.h"
4747
#include "sus/num/unsigned_integer.h"
4848
#include "sus/ops/range.h"
4949
#include "sus/option/option.h"
@@ -115,7 +115,7 @@ class [[sus_trivial_abi]] Slice final {
115115
sus_pure static constexpr Slice from_raw_parts(
116116
::sus::marker::UnsafeFnMarker, const T* data sus_lifetimebound,
117117
usize len) noexcept {
118-
::sus::check(len <= ::sus::mog<usize>(isize::MAX));
118+
::sus::check(len <= ::sus::cast<usize>(isize::MAX));
119119
// We strip the `const` off `data`, however only const access is provided
120120
// through this class. This is done so that mutable types can compose Slice
121121
// and store a mutable pointer.
@@ -150,7 +150,7 @@ class [[sus_trivial_abi]] Slice final {
150150
sus_pure static constexpr Slice from_raw_collection(
151151
::sus::marker::UnsafeFnMarker, ::sus::iter::IterRefCounter refs,
152152
const T* data sus_lifetimebound, usize len) noexcept {
153-
::sus::check(len <= ::sus::mog<usize>(isize::MAX));
153+
::sus::check(len <= ::sus::cast<usize>(isize::MAX));
154154
// We strip the `const` off `data`, however only const access is provided
155155
// through this class. This is done so that mutable types can compose Slice
156156
// and store a mutable pointer.
@@ -163,7 +163,7 @@ class [[sus_trivial_abi]] Slice final {
163163
///
164164
/// #[doc.overloads=from.array]
165165
template <size_t N>
166-
requires(N <= ::sus::mog<usize>(isize::MAX))
166+
requires(N <= ::sus::cast<usize>(isize::MAX))
167167
sus_pure static constexpr Slice from(const T (&data)[N] sus_lifetimebound) {
168168
// We strip the `const` off `data`, however only const access is provided
169169
// through this class. This is done so that mutable types can compose Slice
@@ -342,7 +342,7 @@ class [[sus_trivial_abi]] SliceMut final {
342342
sus_pure static constexpr SliceMut from_raw_parts_mut(
343343
::sus::marker::UnsafeFnMarker, T* data sus_lifetimebound,
344344
usize len) noexcept {
345-
::sus::check(len <= ::sus::mog<usize>(isize::MAX));
345+
::sus::check(len <= ::sus::cast<usize>(isize::MAX));
346346
return SliceMut(::sus::iter::IterRefCounter::empty_for_view(), data, len);
347347
}
348348

@@ -372,7 +372,7 @@ class [[sus_trivial_abi]] SliceMut final {
372372
sus_pure static constexpr SliceMut from_raw_collection_mut(
373373
::sus::marker::UnsafeFnMarker, ::sus::iter::IterRefCounter refs,
374374
T* data sus_lifetimebound, usize len) noexcept {
375-
::sus::check(len <= ::sus::mog<usize>(isize::MAX));
375+
::sus::check(len <= ::sus::cast<usize>(isize::MAX));
376376
return SliceMut(::sus::move(refs), data, len);
377377
}
378378

@@ -382,7 +382,7 @@ class [[sus_trivial_abi]] SliceMut final {
382382
///
383383
/// #[doc.overloads=from.array]
384384
template <size_t N>
385-
requires(N <= ::sus::mog<usize>(isize::MAX_PRIMITIVE))
385+
requires(N <= ::sus::cast<usize>(isize::MAX_PRIMITIVE))
386386
sus_pure static constexpr SliceMut from(T (&data)[N] sus_lifetimebound) {
387387
return SliceMut(::sus::iter::IterRefCounter::empty_for_view(), data, N);
388388
}

sus/collections/vec.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@
5050
#include "sus/mem/relocate.h"
5151
#include "sus/mem/replace.h"
5252
#include "sus/mem/size_of.h"
53+
#include "sus/num/cast.h"
5354
#include "sus/num/integer_concepts.h"
5455
#include "sus/num/signed_integer.h"
55-
#include "sus/num/transmogrify.h"
5656
#include "sus/num/unsigned_integer.h"
5757
#include "sus/ops/range.h"
5858
#include "sus/option/option.h"
@@ -147,7 +147,8 @@ class Vec final {
147147
/// # Panics
148148
/// Panics if the capacity exceeds `isize::MAX` bytes.
149149
sus_pure static constexpr Vec with_capacity(usize capacity) noexcept {
150-
check(::sus::mem::size_of<T>() * capacity <= ::sus::mog<usize>(isize::MAX));
150+
check(::sus::mem::size_of<T>() * capacity <=
151+
::sus::cast<usize>(isize::MAX));
151152
return Vec(WITH_CAPACITY, std::allocator<T>(), capacity);
152153
}
153154

@@ -210,12 +211,12 @@ class Vec final {
210211
requires(std::same_as<T, u8> && //
211212
(std::same_as<C, char> || std::same_as<C, signed char> ||
212213
std::same_as<C, unsigned char>) &&
213-
N <= ::sus::mog<usize>(isize::MAX))
214+
N <= ::sus::cast<usize>(isize::MAX))
214215
static constexpr Vec from(const C (&arr)[N]) {
215216
auto s = sus::Slice<C>::from(arr);
216217
auto v = Vec::with_capacity(N - 1);
217218
for (auto c : s[sus::ops::RangeTo<usize>(N - 1)])
218-
v.push_with_capacity_internal(sus::mog<uint8_t>(c));
219+
v.push_with_capacity_internal(sus::cast<uint8_t>(c));
219220
::sus::check(s[N - 1] == 0); // Null terminated.
220221
return v;
221222
}
@@ -1011,7 +1012,7 @@ Vec(T&&, Ts&&...) -> Vec<std::remove_cvref_t<T>>;
10111012
template <class T>
10121013
constexpr T* Vec<T>::alloc_internal_check_cap(usize cap) noexcept {
10131014
sus_debug_check(!is_alloced());
1014-
::sus::check(cap <= ::sus::mog<usize>(isize::MAX));
1015+
::sus::check(cap <= ::sus::cast<usize>(isize::MAX));
10151016
T* const new_data = std::allocator_traits<A>::allocate(allocator_, cap);
10161017
data_ = new_data;
10171018
capacity_ = cap;
@@ -1022,7 +1023,7 @@ template <class T>
10221023
constexpr T* Vec<T>::grow_to_internal_check_cap(usize cap) noexcept {
10231024
sus_debug_check(is_alloced());
10241025
sus_debug_check(cap > capacity_);
1025-
::sus::check(cap <= ::sus::mog<usize>(isize::MAX));
1026+
::sus::check(cap <= ::sus::cast<usize>(isize::MAX));
10261027
T* const new_data =
10271028
std::allocator_traits<std::allocator<T>>::allocate(allocator_, cap);
10281029
if constexpr (::sus::mem::relocate_by_memcpy<T>) {

sus/collections/vec_unittest.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -1029,22 +1029,22 @@ TEST(Vec, FromCharArray) {
10291029
const signed char SIGNED[] = "abcdefg";
10301030
auto v = Vec<u8>::from(SIGNED);
10311031
EXPECT_EQ(v.len(), 7u);
1032-
EXPECT_EQ(v[0u], sus::mog<u8>('a'));
1033-
EXPECT_EQ(v[6u], sus::mog<u8>('g'));
1032+
EXPECT_EQ(v[0u], sus::cast<u8>('a'));
1033+
EXPECT_EQ(v[6u], sus::cast<u8>('g'));
10341034
}
10351035
{
10361036
const unsigned char UNSIGNED[] = "abcdefg";
10371037
auto v = Vec<u8>::from(UNSIGNED);
10381038
EXPECT_EQ(v.len(), 7u);
1039-
EXPECT_EQ(v[0u], sus::mog<u8>('a'));
1040-
EXPECT_EQ(v[6u], sus::mog<u8>('g'));
1039+
EXPECT_EQ(v[0u], sus::cast<u8>('a'));
1040+
EXPECT_EQ(v[6u], sus::cast<u8>('g'));
10411041
}
10421042
{
10431043
const char CHARS[] = "abcdefg";
10441044
auto v = Vec<u8>::from(CHARS);
10451045
EXPECT_EQ(v.len(), 7u);
1046-
EXPECT_EQ(v[0u], sus::mog<u8>('a'));
1047-
EXPECT_EQ(v[6u], sus::mog<u8>('g'));
1046+
EXPECT_EQ(v[0u], sus::cast<u8>('a'));
1047+
EXPECT_EQ(v[6u], sus::cast<u8>('g'));
10481048
}
10491049
}
10501050

0 commit comments

Comments
 (0)