From e661c57b4fdbf650db31f546bdbf6bb7f2fc41b4 Mon Sep 17 00:00:00 2001 From: PeanutbutterWarrior <50717143+PeanutbutterWarrior@users.noreply.github.com> Date: Sat, 13 Nov 2021 00:08:20 +0000 Subject: [PATCH 01/12] Add rust builder and build script --- SConstruct | 13 ++++++++++--- sconscripts/rust_SConscript | 6 ++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 sconscripts/rust_SConscript diff --git a/SConstruct b/SConstruct index 93354e152..07773477d 100644 --- a/SConstruct +++ b/SConstruct @@ -10,13 +10,19 @@ To run the compilation for all implementations in one language, e.g. C, run the from pathlib import Path import os -env = Environment(ENV={'PATH': os.environ['PATH']}, - tools=['gcc', 'gnulink', 'g++', 'gas']) +# Add other languages here when you want to add language targets +# Put 'name_of_language_directory' : 'file_extension' +languages = {'c': 'c', 'rust': 'rs'} -env['ASFLAGS'] = '--64' +rust_builder = Builder("cargo build --bin $SOURCE --target-dir $TARGET") + +env = Environment(ENV={'PATH': os.environ['PATH']}, + BUILDERS={'Rust': rust_builder}, + tools=['gcc', 'gnulink', 'g++', 'gas']) env['CCFLAGS'] = '' env['CXXFLAGS'] = '-std=c++17' +env['ASFLAGS'] = '--64' # Add other languages here when you want to add language targets # Put 'name_of_language_directory' : 'file_extension' @@ -25,6 +31,7 @@ languages = {'c': 'c', 'cpp': 'cpp', 'asm-x64': 's'} env.C = env.Program env.CPlusPlus = env.Program env.X64 = env.Program +env.rust = rust_builder Export('env') diff --git a/sconscripts/rust_SConscript b/sconscripts/rust_SConscript new file mode 100644 index 000000000..e15611c8d --- /dev/null +++ b/sconscripts/rust_SConscript @@ -0,0 +1,6 @@ +Import('files_to_compile env') +from pathlib import Path + +for file in files_to_compile: + chapter_name = file.parent.parent.parent.stem + env.rust(f'#/build/c/{chapter_name}', str(file)) From a47953719f90f5250ba96213282f0bc0fc8059d9 Mon Sep 17 00:00:00 2001 From: PeanutbutterWarrior <50717143+PeanutbutterWarrior@users.noreply.github.com> Date: Sat, 27 Nov 2021 21:46:54 +0000 Subject: [PATCH 02/12] Move file to be discovered by SCons, and update Cargo.toml to reflect this --- contents/barnsley/code/rust/Cargo.toml | 6 +++++- contents/barnsley/code/rust/{src => }/main.rs | 0 2 files changed, 5 insertions(+), 1 deletion(-) rename contents/barnsley/code/rust/{src => }/main.rs (100%) diff --git a/contents/barnsley/code/rust/Cargo.toml b/contents/barnsley/code/rust/Cargo.toml index 40780594a..35c6ea84f 100644 --- a/contents/barnsley/code/rust/Cargo.toml +++ b/contents/barnsley/code/rust/Cargo.toml @@ -6,4 +6,8 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -rand = "0.8.4" \ No newline at end of file +rand = "0.8.4" + +[[bin]] +path = "./main.rs" +name = "main" \ No newline at end of file diff --git a/contents/barnsley/code/rust/src/main.rs b/contents/barnsley/code/rust/main.rs similarity index 100% rename from contents/barnsley/code/rust/src/main.rs rename to contents/barnsley/code/rust/main.rs From 8f6d1d5745835a384f01c2f25667f3a739d0e98b Mon Sep 17 00:00:00 2001 From: PeanutbutterWarrior <50717143+PeanutbutterWarrior@users.noreply.github.com> Date: Sat, 27 Nov 2021 21:54:07 +0000 Subject: [PATCH 03/12] Add rustc to SCons --- SConstruct | 7 ++++--- sconscripts/rust_SConscript | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index 07773477d..4790e5a69 100644 --- a/SConstruct +++ b/SConstruct @@ -14,10 +14,11 @@ import os # Put 'name_of_language_directory' : 'file_extension' languages = {'c': 'c', 'rust': 'rs'} -rust_builder = Builder("cargo build --bin $SOURCE --target-dir $TARGET") +#rust_cargo_builder = Builder(action="cargo build --bin $SOURCE --target-dir $TARGET") +rust_rustc_builder = Builder(action="rustc $SOURCE -o $TARGET$PROGSUFFIX") env = Environment(ENV={'PATH': os.environ['PATH']}, - BUILDERS={'Rust': rust_builder}, + BUILDERS={'rustc': rust_rustc_builder}, tools=['gcc', 'gnulink', 'g++', 'gas']) env['CCFLAGS'] = '' @@ -31,7 +32,7 @@ languages = {'c': 'c', 'cpp': 'cpp', 'asm-x64': 's'} env.C = env.Program env.CPlusPlus = env.Program env.X64 = env.Program -env.rust = rust_builder +#env.rustc = rust_rustc_builder Export('env') diff --git a/sconscripts/rust_SConscript b/sconscripts/rust_SConscript index e15611c8d..706dff698 100644 --- a/sconscripts/rust_SConscript +++ b/sconscripts/rust_SConscript @@ -3,4 +3,7 @@ from pathlib import Path for file in files_to_compile: chapter_name = file.parent.parent.parent.stem - env.rust(f'#/build/c/{chapter_name}', str(file)) + if (file.parent / 'Cargo.toml').exists(): + print(f"Building with cargo for {chapter_name}") + else: + env.rustc(f'#/build/rust/{chapter_name}', str(file)) From 9e8c460169acaa753f9da6924e3f4ef69c3678bd Mon Sep 17 00:00:00 2001 From: PeanutbutterWarrior <50717143+PeanutbutterWarrior@users.noreply.github.com> Date: Sat, 27 Nov 2021 22:30:04 +0000 Subject: [PATCH 04/12] Add Cargo.toml files for code requiring libraries --- .gitignore | 3 +++ contents/barnsley/code/rust/Cargo.toml | 4 ++-- .../barnsley/code/rust/{main.rs => barnsley.rs} | 0 contents/cooley_tukey/code/rust/Cargo.toml | 14 ++++++++++++++ contents/huffman_encoding/code/rust/Cargo.toml | 13 +++++++++++++ .../monte_carlo_integration/code/rust/Cargo.toml | 13 +++++++++++++ .../split-operator_method/code/rust/Cargo.toml | 14 ++++++++++++++ 7 files changed, 59 insertions(+), 2 deletions(-) rename contents/barnsley/code/rust/{main.rs => barnsley.rs} (100%) create mode 100644 contents/cooley_tukey/code/rust/Cargo.toml create mode 100644 contents/huffman_encoding/code/rust/Cargo.toml create mode 100644 contents/monte_carlo_integration/code/rust/Cargo.toml create mode 100644 contents/split-operator_method/code/rust/Cargo.toml diff --git a/.gitignore b/.gitignore index 231da8ea1..7d85b043c 100644 --- a/.gitignore +++ b/.gitignore @@ -524,3 +524,6 @@ vscode/ # SCons build directory build/ + +# Cargo artifacts +Cargo.lock diff --git a/contents/barnsley/code/rust/Cargo.toml b/contents/barnsley/code/rust/Cargo.toml index 35c6ea84f..52505634b 100644 --- a/contents/barnsley/code/rust/Cargo.toml +++ b/contents/barnsley/code/rust/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "rust" +name = "barnsley" version = "0.1.0" edition = "2018" @@ -9,5 +9,5 @@ edition = "2018" rand = "0.8.4" [[bin]] -path = "./main.rs" +path = "./barnsley.rs" name = "main" \ No newline at end of file diff --git a/contents/barnsley/code/rust/main.rs b/contents/barnsley/code/rust/barnsley.rs similarity index 100% rename from contents/barnsley/code/rust/main.rs rename to contents/barnsley/code/rust/barnsley.rs diff --git a/contents/cooley_tukey/code/rust/Cargo.toml b/contents/cooley_tukey/code/rust/Cargo.toml new file mode 100644 index 000000000..5e0f5cef3 --- /dev/null +++ b/contents/cooley_tukey/code/rust/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "rust" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +rand = "0.8.4" +rustfft = "6.0.1" + +[[bin]] +path = "./fft.rs" +name = "main" \ No newline at end of file diff --git a/contents/huffman_encoding/code/rust/Cargo.toml b/contents/huffman_encoding/code/rust/Cargo.toml new file mode 100644 index 000000000..1add99ad2 --- /dev/null +++ b/contents/huffman_encoding/code/rust/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "huffman" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +itertools = "0.10.1" + +[[bin]] +path = "./huffman.rs" +name = "main" \ No newline at end of file diff --git a/contents/monte_carlo_integration/code/rust/Cargo.toml b/contents/monte_carlo_integration/code/rust/Cargo.toml new file mode 100644 index 000000000..17ff7f385 --- /dev/null +++ b/contents/monte_carlo_integration/code/rust/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "montecarlo" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +rand = "0.8.4" + +[[bin]] +path = "./monte_carlo.rs" +name = "main" \ No newline at end of file diff --git a/contents/split-operator_method/code/rust/Cargo.toml b/contents/split-operator_method/code/rust/Cargo.toml new file mode 100644 index 000000000..daa883d82 --- /dev/null +++ b/contents/split-operator_method/code/rust/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "splitop" +version = "0.1.0" +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +num = "0.4.0" +rustfft = "5.1.1" + +[[bin]] +path = "./split_op.rs" +name = "main" \ No newline at end of file From 931929b39ca4e3a1c2b6acbdeca0959beb6fd6ca Mon Sep 17 00:00:00 2001 From: PeanutbutterWarrior <50717143+PeanutbutterWarrior@users.noreply.github.com> Date: Sun, 28 Nov 2021 15:13:35 +0000 Subject: [PATCH 05/12] Add cargo building when Cargo.toml is present --- SConstruct | 9 ++++++--- sconscripts/rust_SConscript | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index 4790e5a69..7b81d7f1c 100644 --- a/SConstruct +++ b/SConstruct @@ -14,11 +14,14 @@ import os # Put 'name_of_language_directory' : 'file_extension' languages = {'c': 'c', 'rust': 'rs'} -#rust_cargo_builder = Builder(action="cargo build --bin $SOURCE --target-dir $TARGET") -rust_rustc_builder = Builder(action="rustc $SOURCE -o $TARGET$PROGSUFFIX") +rust_cargo_builder = Builder(action=['cargo build --bins --target-dir $TARGET --manifest-path $MANIFEST', + Move('$TARGET$PROGSUFFIX', '$TARGET/debug/main$PROGSUFFIX'), + Delete('$TARGET')]) + +rust_rustc_builder = Builder(action='rustc $SOURCE -o $TARGET$PROGSUFFIX') env = Environment(ENV={'PATH': os.environ['PATH']}, - BUILDERS={'rustc': rust_rustc_builder}, + BUILDERS={'rustc': rust_rustc_builder, 'cargo': rust_cargo_builder}, tools=['gcc', 'gnulink', 'g++', 'gas']) env['CCFLAGS'] = '' diff --git a/sconscripts/rust_SConscript b/sconscripts/rust_SConscript index 706dff698..98760cede 100644 --- a/sconscripts/rust_SConscript +++ b/sconscripts/rust_SConscript @@ -4,6 +4,6 @@ from pathlib import Path for file in files_to_compile: chapter_name = file.parent.parent.parent.stem if (file.parent / 'Cargo.toml').exists(): - print(f"Building with cargo for {chapter_name}") + env.cargo(f'#/build/rust/{chapter_name}', str(file), MANIFEST=str(file.parent / 'Cargo.toml')) else: env.rustc(f'#/build/rust/{chapter_name}', str(file)) From 472bf4eada1b353be54dc3852badf66e1a6e52f9 Mon Sep 17 00:00:00 2001 From: PeanutbutterWarrior <50717143+PeanutbutterWarrior@users.noreply.github.com> Date: Sun, 28 Nov 2021 15:49:56 +0000 Subject: [PATCH 06/12] Fix copying fail on linux due to directory name and file name collision --- SConstruct | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/SConstruct b/SConstruct index 7b81d7f1c..9f0db1ad5 100644 --- a/SConstruct +++ b/SConstruct @@ -14,9 +14,8 @@ import os # Put 'name_of_language_directory' : 'file_extension' languages = {'c': 'c', 'rust': 'rs'} -rust_cargo_builder = Builder(action=['cargo build --bins --target-dir $TARGET --manifest-path $MANIFEST', - Move('$TARGET$PROGSUFFIX', '$TARGET/debug/main$PROGSUFFIX'), - Delete('$TARGET')]) +rust_cargo_builder = Builder(action=['cargo build --bins --manifest-path $MANIFEST', + Move('$TARGET$PROGSUFFIX', '$SOURCE/../target/debug/main$PROGSUFFIX')]) rust_rustc_builder = Builder(action='rustc $SOURCE -o $TARGET$PROGSUFFIX') From 70bdca4d7bb360629b8a9a6cb31110a264c28e94 Mon Sep 17 00:00:00 2001 From: PeanutbutterWarrior <50717143+PeanutbutterWarrior@users.noreply.github.com> Date: Sun, 28 Nov 2021 15:50:34 +0000 Subject: [PATCH 07/12] Add build artifacts to SCons clean command and .gitignore --- .gitignore | 1 + sconscripts/rust_SConscript | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 7d85b043c..4d5a431b0 100644 --- a/.gitignore +++ b/.gitignore @@ -527,3 +527,4 @@ build/ # Cargo artifacts Cargo.lock +target/ diff --git a/sconscripts/rust_SConscript b/sconscripts/rust_SConscript index 98760cede..7bc9d7ac6 100644 --- a/sconscripts/rust_SConscript +++ b/sconscripts/rust_SConscript @@ -5,5 +5,7 @@ for file in files_to_compile: chapter_name = file.parent.parent.parent.stem if (file.parent / 'Cargo.toml').exists(): env.cargo(f'#/build/rust/{chapter_name}', str(file), MANIFEST=str(file.parent / 'Cargo.toml')) + env.Clean('rust', str(file.parent / 'target')) else: env.rustc(f'#/build/rust/{chapter_name}', str(file)) + env.Clean('rust', f'#/build/rust/{chapter_name}.pdb') From 3a352f7a29e11fdbdaa6200c10010a068d35c5da Mon Sep 17 00:00:00 2001 From: PeanutbutterWarrior <50717143+PeanutbutterWarrior@users.noreply.github.com> Date: Sun, 28 Nov 2021 16:43:50 +0000 Subject: [PATCH 08/12] Fix Not a directory issue due to getting parent directory of a file --- SConstruct | 2 +- sconscripts/rust_SConscript | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index 9f0db1ad5..1cac74112 100644 --- a/SConstruct +++ b/SConstruct @@ -15,7 +15,7 @@ import os languages = {'c': 'c', 'rust': 'rs'} rust_cargo_builder = Builder(action=['cargo build --bins --manifest-path $MANIFEST', - Move('$TARGET$PROGSUFFIX', '$SOURCE/../target/debug/main$PROGSUFFIX')]) + Move('$TARGET$PROGSUFFIX', '$SOURCE_DIR/target/debug/main$PROGSUFFIX')]) rust_rustc_builder = Builder(action='rustc $SOURCE -o $TARGET$PROGSUFFIX') diff --git a/sconscripts/rust_SConscript b/sconscripts/rust_SConscript index 7bc9d7ac6..b9cf669c7 100644 --- a/sconscripts/rust_SConscript +++ b/sconscripts/rust_SConscript @@ -4,7 +4,10 @@ from pathlib import Path for file in files_to_compile: chapter_name = file.parent.parent.parent.stem if (file.parent / 'Cargo.toml').exists(): - env.cargo(f'#/build/rust/{chapter_name}', str(file), MANIFEST=str(file.parent / 'Cargo.toml')) + env.cargo(target=f'#/build/rust/{chapter_name}', + source=str(file), + MANIFEST=str(file.parent / 'Cargo.toml'), + SOURCE_DIR=str(file.parent)) env.Clean('rust', str(file.parent / 'target')) else: env.rustc(f'#/build/rust/{chapter_name}', str(file)) From a4f63ab39561f8f23bb39777450bd63303478e2c Mon Sep 17 00:00:00 2001 From: PeanutbutterWarrior <50717143+PeanutbutterWarrior@users.noreply.github.com> Date: Sun, 28 Nov 2021 16:58:26 +0000 Subject: [PATCH 09/12] Remove redefinition of languages dictionary --- SConstruct | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/SConstruct b/SConstruct index 1cac74112..1a20bf633 100644 --- a/SConstruct +++ b/SConstruct @@ -10,16 +10,12 @@ To run the compilation for all implementations in one language, e.g. C, run the from pathlib import Path import os -# Add other languages here when you want to add language targets -# Put 'name_of_language_directory' : 'file_extension' -languages = {'c': 'c', 'rust': 'rs'} - rust_cargo_builder = Builder(action=['cargo build --bins --manifest-path $MANIFEST', Move('$TARGET$PROGSUFFIX', '$SOURCE_DIR/target/debug/main$PROGSUFFIX')]) rust_rustc_builder = Builder(action='rustc $SOURCE -o $TARGET$PROGSUFFIX') -env = Environment(ENV={'PATH': os.environ['PATH']}, +env = Environment(ENV=os.environ, BUILDERS={'rustc': rust_rustc_builder, 'cargo': rust_cargo_builder}, tools=['gcc', 'gnulink', 'g++', 'gas']) @@ -29,12 +25,11 @@ env['ASFLAGS'] = '--64' # Add other languages here when you want to add language targets # Put 'name_of_language_directory' : 'file_extension' -languages = {'c': 'c', 'cpp': 'cpp', 'asm-x64': 's'} +languages = {'c': 'c', 'cpp': 'cpp', 'asm-x64': 's', 'rust': 'rs'} env.C = env.Program env.CPlusPlus = env.Program env.X64 = env.Program -#env.rustc = rust_rustc_builder Export('env') From 616ce2016fc1f6b2bdc6e2d1d354a379096343b5 Mon Sep 17 00:00:00 2001 From: PeanutbutterWarrior <50717143+PeanutbutterWarrior@users.noreply.github.com> Date: Sun, 28 Nov 2021 18:27:52 +0000 Subject: [PATCH 10/12] Add rustc and cargo install to docker --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d6ecdfc45..a0808c1ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT} # [Optional] Uncomment this section to install additional OS packages. RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ - && apt-get -y install --no-install-recommends build-essential software-properties-common xz-utils g++ sbcl julia python3 python3-pip python3-dev ghc openjdk-11-jdk rustc libssl-dev gfortran libxml2-dev libyaml-dev libgmp-dev libz-dev libncurses5 gnuplot nodejs npm lua5.3 ocaml php ruby-full gnu-smalltalk scratch libfftw3-dev cmake + && apt-get -y install --no-install-recommends build-essential software-properties-common xz-utils g++ sbcl julia python3 python3-pip python3-dev ghc openjdk-11-jdk libssl-dev gfortran libxml2-dev libyaml-dev libgmp-dev libz-dev libncurses5 gnuplot nodejs npm lua5.3 ocaml php ruby-full gnu-smalltalk scratch libfftw3-dev cmake # Setup Crystal RUN echo 'deb http://download.opensuse.org/repositories/devel:/languages:/crystal/xUbuntu_20.04/ /' | sudo tee /etc/apt/sources.list.d/devel:languages:crystal.list @@ -72,6 +72,9 @@ RUN sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu fo RUN sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D9D33FCD84D82C17288BA03B3C9A6980F827E01E RUN sudo add-apt-repository 'deb http://ppa.launchpad.net/plt/racket/ubuntu focal main' +# Setup Rust +RUN curl https://sh.rustup.rs -sSf | sh -s -- -y + # Setup Scratch ## using 1.x right now.... in future checkout snap or adobe air? From d4e3652722d4fdb129e7b7f4cf87f77a6dc7e2fe Mon Sep 17 00:00:00 2001 From: PeanutbutterWarrior <50717143+PeanutbutterWarrior@users.noreply.github.com> Date: Sun, 28 Nov 2021 20:28:39 +0000 Subject: [PATCH 11/12] Update Cooley-Tukey to use correct version of crates --- contents/cooley_tukey/code/rust/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contents/cooley_tukey/code/rust/Cargo.toml b/contents/cooley_tukey/code/rust/Cargo.toml index 5e0f5cef3..0cba5179d 100644 --- a/contents/cooley_tukey/code/rust/Cargo.toml +++ b/contents/cooley_tukey/code/rust/Cargo.toml @@ -6,8 +6,8 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -rand = "0.8.4" -rustfft = "6.0.1" +rand = "0.7.3" +rustfft = "4.1.0" [[bin]] path = "./fft.rs" From b468db1f0b81e82b5951871932edadf12f34be72 Mon Sep 17 00:00:00 2001 From: PeanutbutterWarrior <50717143+PeanutbutterWarrior@users.noreply.github.com> Date: Sun, 28 Nov 2021 20:43:56 +0000 Subject: [PATCH 12/12] Update split-operator method to use correct library versions and apply fixes from #688 --- contents/split-operator_method/code/rust/Cargo.toml | 3 +-- contents/split-operator_method/code/rust/split_op.rs | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/contents/split-operator_method/code/rust/Cargo.toml b/contents/split-operator_method/code/rust/Cargo.toml index daa883d82..def85c23e 100644 --- a/contents/split-operator_method/code/rust/Cargo.toml +++ b/contents/split-operator_method/code/rust/Cargo.toml @@ -6,8 +6,7 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -num = "0.4.0" -rustfft = "5.1.1" +rustfft = "4.1.0" [[bin]] path = "./split_op.rs" diff --git a/contents/split-operator_method/code/rust/split_op.rs b/contents/split-operator_method/code/rust/split_op.rs index 7269f5148..d29e16a2e 100644 --- a/contents/split-operator_method/code/rust/split_op.rs +++ b/contents/split-operator_method/code/rust/split_op.rs @@ -1,7 +1,6 @@ -extern crate num; extern crate rustfft; -use num::complex::Complex; +use rustfft::num_complex::Complex; use rustfft::FFTplanner; use std::f64::consts::PI; use std::fs::File; @@ -95,7 +94,7 @@ fn fft(x: &mut Vec>, inverse: bool) { let mut y = vec![Complex::new(0.0_f64, 0.0_f64); x.len()]; let mut p = FFTplanner::new(inverse); let fft = p.plan_fft(x.len()); - fft.process(x, &mut y); + fft.process(x.as_mut_slice(), y.as_mut_slice()); for i in 0..x.len() { x[i] = y[i] / (x.len() as f64).sqrt();