Skip to content

Commit a116b5a

Browse files
authored
Merge pull request #214 from FenrirWolf/update_edition
Update ctru-rs to the 2024 edition.
2 parents 786af2b + fe023e2 commit a116b5a

File tree

17 files changed

+50
-41
lines changed

17 files changed

+50
-41
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
matrix:
1616
toolchain:
1717
# Run against a "known good" nightly. Rustc version is 1 day behind the toolchain date
18-
- nightly-2024-03-10
18+
- nightly-2025-03-30
1919
# Check for breakage on latest nightly
2020
- nightly
2121

@@ -54,7 +54,7 @@ jobs:
5454
strategy:
5555
matrix:
5656
toolchain:
57-
- nightly-2024-03-10
57+
- nightly-2025-03-30
5858
- nightly
5959
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
6060
runs-on: ubuntu-latest

ctru-rs/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ keywords = ["3ds", "libctru"]
99
categories = ["os", "api-bindings", "hardware-support"]
1010
exclude = ["examples"]
1111
license = "Zlib"
12-
edition = "2021"
13-
rust-version = "1.78"
12+
edition = "2024"
13+
rust-version = "1.85"
1414

1515
[lib]
1616
crate-type = ["rlib"]

ctru-rs/examples/audio-filters.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use std::f32::consts::PI;
99
use ctru::linear::LinearAllocator;
1010
use ctru::prelude::*;
1111
use ctru::services::ndsp::{
12-
wave::{Status, Wave},
1312
AudioFormat, AudioMix, InterpolationType, Ndsp, OutputMode,
13+
wave::{Status, Wave},
1414
};
1515

1616
// Configuration for the NDSP process and channels.

ctru-rs/examples/file-explorer.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ impl<'a> FileExplorer<'a> {
104104
}
105105
};
106106

107-
println!("Press Start to exit, A to select an entry by number, B to go up a directory, X to set the path.");
107+
println!(
108+
"Press Start to exit, A to select an entry by number, B to go up a directory, X to set the path."
109+
);
108110
}
109111

110112
fn print_dir_entries(&mut self) {

ctru-rs/examples/ir-user-circle-pad-pro.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const CPP_POLLING_PERIOD_MS: u8 = 0x32;
1919

2020
// This export tells libctru to not initialize ir:rst when initializing HID.
2121
// This is necessary on the New 3DS because ir:rst is mutually exclusive with ir:USER.
22-
#[no_mangle]
22+
#[unsafe(no_mangle)]
2323
unsafe extern "C" fn hidShouldUseIrrst() -> bool {
2424
false
2525
}

ctru-rs/examples/local-networking.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ fn main() -> Result<(), Error> {
120120
if networks.len() == 1 { "" } else { "s" }
121121
);
122122

123-
println!("D-Pad to select, A to connect as client, R + A to connect as spectator, B to create a new network");
123+
println!(
124+
"D-Pad to select, A to connect as client, R + A to connect as spectator, B to create a new network"
125+
);
124126

125127
for (index, n) in networks.iter().enumerate() {
126128
println!(
@@ -238,7 +240,7 @@ fn main() -> Result<(), Error> {
238240
let appdata = [0x69u8, 0x8a, 0x05, 0x5c]
239241
.into_iter()
240242
.chain((*b"Test appdata.").into_iter())
241-
.chain(std::iter::repeat(0).take(3))
243+
.chain(std::iter::repeat_n(0, 3))
242244
.collect::<Vec<_>>();
243245

244246
uds.set_appdata(&appdata)?;

ctru-rs/src/applets/swkbd.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
use crate::services::{apt::Apt, gfx::Gfx};
77
use ctru_sys::{
8-
aptLaunchLibraryApplet, aptSetMessageCallback, envGetAptAppId, svcCloseHandle,
9-
svcCreateMemoryBlock, APT_SendParameter, SwkbdButton, SwkbdDictWord, SwkbdLearningData,
10-
SwkbdState, SwkbdStatusData, APPID_SOFTWARE_KEYBOARD, APTCMD_MESSAGE, NS_APPID,
8+
APPID_SOFTWARE_KEYBOARD, APT_SendParameter, APTCMD_MESSAGE, NS_APPID, SwkbdButton,
9+
SwkbdDictWord, SwkbdLearningData, SwkbdState, SwkbdStatusData, aptLaunchLibraryApplet,
10+
aptSetMessageCallback, envGetAptAppId, svcCloseHandle, svcCreateMemoryBlock,
1111
};
1212

1313
use bitflags::bitflags;
@@ -733,15 +733,12 @@ impl SoftwareKeyboard {
733733
// `self` is allowed to be moved again, we can safely use a pointer to the local value contained in `self.filter_callback`
734734
// The cast here is also sound since the pointer will only be read from if `self.filter_callback.is_some()` returns true.
735735
let mut data = MessageCallbackData {
736-
filter_callback: std::ptr::addr_of!(self.filter_callback).cast(),
736+
filter_callback: (&raw const self.filter_callback).cast(),
737737
swkbd_shared_mem_ptr,
738738
};
739739

740740
if self.filter_callback.is_some() {
741-
aptSetMessageCallback(
742-
Some(Self::swkbd_message_callback),
743-
std::ptr::addr_of_mut!(data).cast(),
744-
)
741+
aptSetMessageCallback(Some(Self::swkbd_message_callback), (&raw mut data).cast())
745742
}
746743

747744
aptLaunchLibraryApplet(

ctru-rs/src/console.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
use std::cell::{RefMut, UnsafeCell};
99

10-
use ctru_sys::{consoleClear, consoleInit, consoleSelect, consoleSetWindow, PrintConsole};
10+
use ctru_sys::{PrintConsole, consoleClear, consoleInit, consoleSelect, consoleSetWindow};
1111

1212
use crate::services::gfx::{Flush, Screen, Swap};
1313

@@ -142,7 +142,7 @@ impl<'screen> Console<'screen> {
142142
/// ```
143143
pub fn exists() -> bool {
144144
unsafe {
145-
let current_console = ctru_sys::consoleSelect(std::ptr::addr_of_mut!(EMPTY_CONSOLE));
145+
let current_console = ctru_sys::consoleSelect(&raw mut EMPTY_CONSOLE);
146146

147147
let res = (*current_console).consoleInitialised;
148148

@@ -366,7 +366,7 @@ impl Drop for Console<'_> {
366366
// the screen, but it won't crash either.
367367

368368
// Get the current console by replacing it with an empty one.
369-
let current_console = ctru_sys::consoleSelect(std::ptr::addr_of_mut!(EMPTY_CONSOLE));
369+
let current_console = ctru_sys::consoleSelect(&raw mut EMPTY_CONSOLE);
370370

371371
if std::ptr::eq(current_console, self.context.get()) {
372372
// Console dropped while selected. We just replaced it with the

ctru-rs/src/error.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,10 @@ impl fmt::Display for Error {
178178
Self::OutputAlreadyRedirected => {
179179
write!(f, "output streams are already redirected to 3dslink")
180180
}
181-
Self::BufferTooShort{provided, wanted} => write!(f, "the provided buffer's length is too short (length = {provided}) to hold the wanted data (size = {wanted})"),
181+
Self::BufferTooShort { provided, wanted } => write!(
182+
f,
183+
"the provided buffer's length is too short (length = {provided}) to hold the wanted data (size = {wanted})"
184+
),
182185
Self::Other(err) => write!(f, "{err}"),
183186
}
184187
}
@@ -236,9 +239,9 @@ fn result_code_description_str(result: ctru_sys::Result) -> Cow<'static, str> {
236239
RD_ALREADY_DONE, RD_ALREADY_EXISTS, RD_ALREADY_INITIALIZED, RD_BUSY, RD_CANCEL_REQUESTED,
237240
RD_INVALID_ADDRESS, RD_INVALID_COMBINATION, RD_INVALID_ENUM_VALUE, RD_INVALID_HANDLE,
238241
RD_INVALID_POINTER, RD_INVALID_RESULT_VALUE, RD_INVALID_SELECTION, RD_INVALID_SIZE,
239-
RD_MISALIGNED_ADDRESS, RD_MISALIGNED_SIZE, RD_NOT_AUTHORIZED, RD_NOT_FOUND,
240-
RD_NOT_IMPLEMENTED, RD_NOT_INITIALIZED, RD_NO_DATA, RD_OUT_OF_MEMORY, RD_OUT_OF_RANGE,
241-
RD_SUCCESS, RD_TIMEOUT, RD_TOO_LARGE,
242+
RD_MISALIGNED_ADDRESS, RD_MISALIGNED_SIZE, RD_NO_DATA, RD_NOT_AUTHORIZED, RD_NOT_FOUND,
243+
RD_NOT_IMPLEMENTED, RD_NOT_INITIALIZED, RD_OUT_OF_MEMORY, RD_OUT_OF_RANGE, RD_SUCCESS,
244+
RD_TIMEOUT, RD_TOO_LARGE,
242245
};
243246

244247
Cow::Borrowed(match R_DESCRIPTION(result) {
@@ -280,7 +283,7 @@ fn result_code_description_str(result: ctru_sys::Result) -> Cow<'static, str> {
280283
fn result_code_module_str(result: ctru_sys::Result) -> Cow<'static, str> {
281284
use ctru_sys::{
282285
RM_AC, RM_ACC, RM_ACT, RM_AM, RM_AM_LOW, RM_APPLET, RM_APPLICATION, RM_AVD, RM_BOSS,
283-
RM_CAM, RM_CARD, RM_CARDNOR, RM_CARD_SPI, RM_CEC, RM_CODEC, RM_COMMON, RM_CONFIG, RM_CSND,
286+
RM_CAM, RM_CARD, RM_CARD_SPI, RM_CARDNOR, RM_CEC, RM_CODEC, RM_COMMON, RM_CONFIG, RM_CSND,
284287
RM_CUP, RM_DBG, RM_DBM, RM_DD, RM_DI, RM_DLP, RM_DMNT, RM_DSP, RM_EC, RM_ENC, RM_FATFS,
285288
RM_FILE_SERVER, RM_FND, RM_FRIENDS, RM_FS, RM_FSI, RM_GD, RM_GPIO, RM_GSP, RM_GYROSCOPE,
286289
RM_HID, RM_HIO, RM_HIO_LOW, RM_HTTP, RM_I2C, RM_INVALIDRESVAL, RM_IR, RM_KERNEL, RM_L2B,

ctru-rs/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#![feature(custom_test_frameworks)]
2323
#![feature(try_trait_v2)]
2424
#![feature(allocator_api)]
25-
#![feature(new_uninit)]
2625
#![test_runner(test_runner::run_gdb)] // TODO: does this make sense to have configurable?
2726
#![doc(
2827
html_favicon_url = "https://user-images.githubusercontent.com/11131775/225929072-2fa1741c-93ae-4b47-9bdf-af70f3d59910.png"
@@ -41,7 +40,7 @@ extern crate shim_3ds;
4140
/// It takes effect only if the `big-stack` feature is active. Otherwise, the default stack size should be ~32kB.
4241
///
4342
/// This value was chosen to support crate dependencies which expected more stack than provided. It's suggested to use less stack if possible.
44-
#[no_mangle]
43+
#[unsafe(no_mangle)]
4544
// When building lib tests, we don't want to redefine the same symbol twice,
4645
// since ctru-rs is both the crate under test and a dev-dependency (non-test).
4746
// We might also be able to use #[linkage] for similar effect, but this way

0 commit comments

Comments
 (0)