text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: J-AugustoManzano/livro_Rust path: /ExerciciosFixacao/Cap07/c07Exer3C/src/main.rs use std::io; use std::io::prelude::*; fn main() { let mut a: [[f32; 8]; 8] = [[0.0; 8]; 8]; <|fim_suffix|> println!(); print!("Tecle <Enter> para encerrar..."); io::stdout().fl...
code_fim
hard
{ "lang": "rust", "repo": "J-AugustoManzano/livro_Rust", "path": "/ExerciciosFixacao/Cap07/c07Exer3C/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.batch_execute(&generate_query("first", "id"))?; self.batch_execute(&generate_query("fastest", "execution_time"))?; self.batch_execute(&generate_query("shortest", "length"))?; Ok(()) } }<|fim_prefix|>// repo: zerokpr/AtCoderProblems path: /atcoder-problems-backend/...
code_fim
hard
{ "lang": "rust", "repo": "zerokpr/AtCoderProblems", "path": "/atcoder-problems-backend/src/sql/problems_submissions.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: zerokpr/AtCoderProblems path: /atcoder-problems-backend/src/sql/problems_submissions.rs use crate::error::Result; use diesel; use diesel::connection::SimpleConnection; use diesel::PgConnection; fn generate_query(table: &str, column: &str) -> String { format!( r" INS...
code_fim
hard
{ "lang": "rust", "repo": "zerokpr/AtCoderProblems", "path": "/atcoder-problems-backend/src/sql/problems_submissions.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: andrewhickman/shardik path: /src/client/logger.rs use std::iter; use crossbeam_queue::SegQueue; use env_logger::filter::{self, Filter}; use env_logger::DEFAULT_FILTER_ENV; use lazy_static::lazy_static; use log::Log; lazy_static! { static ref LOGGER: Logger = Logger::new(); } pub fn init()...
code_fim
medium
{ "lang": "rust", "repo": "andrewhickman/shardik", "path": "/src/client/logger.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn log(&self, record: &log::Record) { if self.filter.matches(record) { self.queue .push(format!("{}: {}", record.level(), record.args())); } } fn flush(&self) {} }<|fim_prefix|>// repo: andrewhickman/shardik path: /src/client/logger.rs use std::ite...
code_fim
hard
{ "lang": "rust", "repo": "andrewhickman/shardik", "path": "/src/client/logger.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dongri/team path: /src/models/gist.rs use postgres::error::Error; use db; use models; use helper; use chrono::{NaiveDateTime}; #[derive(Serialize, Debug)] pub struct Gist { pub id: i32, pub user_id: i32, pub description: String, pub filename: String, pub code: String, pu...
code_fim
hard
{ "lang": "rust", "repo": "dongri/team", "path": "/src/models/gist.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub fn get_comment_by_id(conn: &db::PostgresConnection, id: &i32) -> Result<Comment, Error> { let rows = &conn.query("SELECT c.*, u.username, u.icon_url from gist_comments as c join users as u on u.id = c.user_id where c.id = $1", &[&id]).unwrap(); let row = rows.get(0); let comment = Comment ...
code_fim
hard
{ "lang": "rust", "repo": "dongri/team", "path": "/src/models/gist.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: millerjs/harNes path: /src/memory.rs use address::*; use types::*; use cartridge::Cartridge; use mappers; pub const MEMORY_SIZE: usize = 65536; pub const RAM_SIZE: usize = 2048; pub trait Memory { fn read(&self, address: Word) -> Byte; fn write(&mut self, address: Word, value: Byte); }...
code_fim
hard
{ "lang": "rust", "repo": "millerjs/harNes", "path": "/src/memory.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>impl MappedMemory { pub fn insert_cartridge(mut self, cartridge: Cartridge) -> Self { self.mapper = mappers::from_cartridge(cartridge); self } } pub enum AddressMapping { Ram, Ppu, Input, Apu, Mapper, } impl AddressMapping { pub fn from_word(word: Word) ->...
code_fim
hard
{ "lang": "rust", "repo": "millerjs/harNes", "path": "/src/memory.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub mod event; pub mod query; pub mod thirdparty;<|fim_prefix|>// repo: matrix-spaces-generator/ruma path: /ruma-appservice-api/src/lib.rs //! Crate ruma_appservice_api contains serializable types for the requests and responses for each //! endpoint in the [Matrix](https://matrix.org/) application servic...
code_fim
easy
{ "lang": "rust", "repo": "matrix-spaces-generator/ruma", "path": "/ruma-appservice-api/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: matrix-spaces-generator/ruma path: /ruma-appservice-api/src/lib.rs //! Crate ruma_appservice_api contains serializable types for the requests and responses for each //! endpoint in the [Matrix](https://matrix.org/) application service API specification. These //! types can be shared by applicati...
code_fim
easy
{ "lang": "rust", "repo": "matrix-spaces-generator/ruma", "path": "/ruma-appservice-api/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: FedericoAureliano/llama path: /src/smt/mod.rs use std::process::Command; use std::io::Write; use std::fs::File; use std::env; use crate::qry::{Query}; use crate::ctx::Solution; impl Query { fn write_to_tmp(&self) -> String { debug!("writing {}", self); let mut dir = env::te...
code_fim
hard
{ "lang": "rust", "repo": "FedericoAureliano/llama", "path": "/src/smt/mod.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let sol_cvc4 = q.check_cvc4().expect("could not parse"); assert!(q.eval(&sol_cvc4).unwrap()); } #[test] fn test_z3_qfuflia() { use std::fs; let unparsed_file = fs::read_to_string("tests/data/qfuflia.smt2").expect("cannot read file"); let mut q = Query::...
code_fim
hard
{ "lang": "rust", "repo": "FedericoAureliano/llama", "path": "/src/smt/mod.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> gemv(ROW_MAJOR, trans_val(trans), rows as i32, cols as i32, product_factor, matrix.as_ptr(), (matrix.len() / rows) as i32, in_vector.as_ptr(), in_vector_inc as i32, out_vector_factor, out_vector.as_mut_ptr(), out_vector_inc as i32); O...
code_fim
hard
{ "lang": "rust", "repo": "ababo/gollum", "path": "/src/cblas.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> matrix: &[f64], in_vector: &[f64], in_vector_inc: usize, product_factor: f64, out_vector: &mut [f64], out_vector_inc: usize, out_vector_factor: f64) -> Result<(), Error> { self.do_gemv(self.dgemv, trans, cols, rows, matrix, in_vector, in_vector_inc, ...
code_fim
hard
{ "lang": "rust", "repo": "ababo/gollum", "path": "/src/cblas.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ababo/gollum path: /src/cblas.rs use blas::{Blas, Error, Transpose}; use dylib::DynamicLibrary; use std::mem::transmute; use std::path::Path; pub struct Cblas { #[allow(dead_code)] dylib: DynamicLibrary, sgemv: usize, dgemv: usize } const ROW_MAJOR: i32 = 101; fn trans_val(tra...
code_fim
hard
{ "lang": "rust", "repo": "ababo/gollum", "path": "/src/cblas.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> alt some(src) { some(src_id) { uint::range(0u, 10u) {|i| let yyy = src_id; assert (yyy == 0u); } } _ { } } } fn main() { foo(0u); }<|fim_prefix|>// repo: nikomatsakis/rust path: /src/test/run-pass/pattern-bound-var-in-for-each.rs // Tests...
code_fim
easy
{ "lang": "rust", "repo": "nikomatsakis/rust", "path": "/src/test/run-pass/pattern-bound-var-in-for-each.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|> alt some(src) { some(src_id) { uint::range(0u, 10u) {|i| let yyy = src_id; assert (yyy == 0u); } } _ { } } } fn main() { foo(0u); }<|fim_prefix|>// repo: nikomatsakis/rust path: /src/test/run-pass/pattern-bound-var-in-for-each.rs // Test...
code_fim
easy
{ "lang": "rust", "repo": "nikomatsakis/rust", "path": "/src/test/run-pass/pattern-bound-var-in-for-each.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nikomatsakis/rust path: /src/test/run-pass/pattern-bound-var-in-for-each.rs // Tests that trans_path checks whether a // pattern-bound var is an upvar (when translating // the for-each body) <|fim_suffix|> alt some(src) { some(src_id) { uint::range(0u, 10u) {|i| let...
code_fim
easy
{ "lang": "rust", "repo": "nikomatsakis/rust", "path": "/src/test/run-pass/pattern-bound-var-in-for-each.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gitter-badger/arangodb-rust-driver path: /tests/test_fixture/mod.rs use std::env; use std::panic; use dotenv::dotenv; use log4rs; use tokio_core::reactor::Core; use arangodb_client::api::types::Empty; use arangodb_client::connection::Connection; use arangodb_client::database::{CreateDatabase,...
code_fim
hard
{ "lang": "rust", "repo": "gitter-badger/arangodb-rust-driver", "path": "/tests/test_fixture/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert!(created, "Error on setting up test database"); } #[allow(dead_code)] fn teardown_database<U, D>(user: U, database: D, conn: &Connection, core: &mut Core) where U: Into<String>, D: Into<String> { let _ = core.run(conn.execute(DropDatabase::with_name(database))).unwrap(); let _ = co...
code_fim
hard
{ "lang": "rust", "repo": "gitter-badger/arangodb-rust-driver", "path": "/tests/test_fixture/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ordovicia/controlgroup-rs path: /src/v1/macros.rs macro_rules! gen_doc { (reads; $file: expr, $desc: literal $( : $detail: literal )?) => { concat!( "Reads ", $desc, " from `", $file, "` file.", $( " ", $detail, )? "\n\n", ) }; (reads_see; $file: expr, $method: ident)...
code_fim
hard
{ "lang": "rust", "repo": "ordovicia/controlgroup-rs", "path": "/src/v1/macros.rs", "mode": "psm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_suffix|>let mut cgroup = ", stringify!($subsys), "::Subsystem::new( CgroupPath::new(SubsystemKind::", _kind!($subsys), ", PathBuf::from(\"students/charlie\"))); cgroup.", stringify!($setter), "(", stringify!($( $val ),* ), ")?; # Ok(()) # } ```") }; (_see_method; $method: ident) => { concat!( " ...
code_fim
hard
{ "lang": "rust", "repo": "ordovicia/controlgroup-rs", "path": "/src/v1/macros.rs", "mode": "spm", "license": "LicenseRef-scancode-unknown-license-reference", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alibaba/GraphScope path: /interactive_engine/executor/engine/pegasus/pegasus/src/operator/primitives/branch.rs // //! Copyright 2020 Alibaba Group Holding Limited. //! //! Licensed under the Apache License, Version 2.0 (the "License"); //! you may not use this file except in compliance with the ...
code_fim
hard
{ "lang": "rust", "repo": "alibaba/GraphScope", "path": "/interactive_engine/executor/engine/pegasus/pegasus/src/operator/primitives/branch.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<D: Data, L: Data, R: Data, F> BranchOperator<D, L, R, F> where F: FnMut(&mut Input<D>, &Output<L>, &Output<R>) -> Result<(), JobExecError> + Send + 'static, { fn new(func: F) -> Self { BranchOperator { func, _ph: std::marker::PhantomData } } } impl<D: Data, L: Data, R: Data, F> O...
code_fim
medium
{ "lang": "rust", "repo": "alibaba/GraphScope", "path": "/interactive_engine/executor/engine/pegasus/pegasus/src/operator/primitives/branch.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> println!("Tell me about {:?}", pair); match pair { (x, y) if x + y == 0 => println!("Antimatter, kaboom!"), (x, y) if x == y => println!("These are twins"), // ^ `if` 条件部分是一个卫语句 (x, _) if x % 2 == 1 => println!("The first one is odd"), _ => println!("No corr...
code_fim
hard
{ "lang": "rust", "repo": "onlytiancai/codesnip", "path": "/rust/022.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: onlytiancai/codesnip path: /rust/022.rs fn main() { struct Foo { x: (u32, u32), y: u32 } // 解构结构体的成员 let foo = Foo { x: (1, 2), y: 3 }; let Foo { x: (a, b), y } = foo; println!("a = {}, b = {}, y = {} ", a, b, y); <|fim_suffix|> let pair = (0, 0); // 试一试 ^ 将不同的值赋给 ...
code_fim
hard
{ "lang": "rust", "repo": "onlytiancai/codesnip", "path": "/rust/022.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: splintersuidman/tini path: /src/interpreter/error.rs use crate::{Identifier, Position}; use std::error; use std::fmt; /// The error type of `Interpreter`. #[derive(Debug)] pub enum InterpreterError { /// An unknown variable name was found. UnknownVariable { name: Identifier, ...
code_fim
hard
{ "lang": "rust", "repo": "splintersuidman/tini", "path": "/src/interpreter/error.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use self::InterpreterError::*; match self { UnknownVariable { name, position } => { write!(f, "unknown variable {} at {}", name, position) } TypeError { expected, found, position, ...
code_fim
hard
{ "lang": "rust", "repo": "splintersuidman/tini", "path": "/src/interpreter/error.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: hideakitai/Sketches path: /s034_wgpu_refactor/src/renderer/draw/primitive/tri.rs use crate::renderer::draw::primitive::polygon::{self, PolygonInit, PolygonOptions, SetPolygon}; use crate::renderer::draw::primitive::Primitive; use crate::renderer::draw::properties::spatial::{dimension, orientatio...
code_fim
hard
{ "lang": "rust", "repo": "hideakitai/Sketches", "path": "/s034_wgpu_refactor/src/renderer/draw/primitive/tri.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> SetStroke::stroke_options_mut(&mut self.polygon) } } impl<S> SetPolygon<S> for Tri<S> { fn polygon_options_mut(&mut self) -> &mut PolygonOptions<S> { SetPolygon::polygon_options_mut(&mut self.polygon) } } // Primitive conversions. impl<S> From<Tri<S>> for Primitive<S> { ...
code_fim
hard
{ "lang": "rust", "repo": "hideakitai/Sketches", "path": "/s034_wgpu_refactor/src/renderer/draw/primitive/tri.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl<S> SetColor<ColorScalar> for Tri<S> { fn rgba_mut(&mut self) -> &mut Option<LinSrgba> { SetColor::rgba_mut(&mut self.polygon) } } impl<S> SetStroke for Tri<S> { fn stroke_options_mut(&mut self) -> &mut StrokeOptions { SetStroke::stroke_options_mut(&mut self.polygon) }...
code_fim
hard
{ "lang": "rust", "repo": "hideakitai/Sketches", "path": "/s034_wgpu_refactor/src/renderer/draw/primitive/tri.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ramsayleung/rspotify path: /tests/test_oauth2.rs use chrono::prelude::*; use chrono::Duration; use rspotify::{ prelude::*, scopes, AuthCodeSpotify, ClientCredsSpotify, Config, Credentials, OAuth, Token, }; use std::{collections::HashMap, fs, io::Read, path::PathBuf}; use url::Url; #[test] f...
code_fim
hard
{ "lang": "rust", "repo": "ramsayleung/rspotify", "path": "/tests/test_oauth2.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_parse_response_code() { // A random state is generated by default let spotify = AuthCodeSpotify::default(); // No `code` parameter let url = "http://localhost:8888/callback"; let code = spotify.parse_response_code(url); assert_eq!(code, None); // No `state` pa...
code_fim
hard
{ "lang": "rust", "repo": "ramsayleung/rspotify", "path": "/tests/test_oauth2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: viddler-no/viddler-cli path: /tools/log_server/src/comp.rs mod data_table; mod doc; pub use data_table::DataTable; pub use doc::Doc; use crate::db::Db; use crate::error::Result; pub trait Comp { fn html(&self, c: HtmlCtx); } <|fim_suffix|>impl CompBox { pub fn new(comp: Box<dyn Comp>...
code_fim
medium
{ "lang": "rust", "repo": "viddler-no/viddler-cli", "path": "/tools/log_server/src/comp.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub struct HtmlCtx<'b, 'd, 'c> { pub buffer: &'b mut String, pub db: &'d Db, pub children: &'c Vec<CompBox>, } impl<'b, 'd, 'c> HtmlCtx<'b, 'd, 'c> { pub fn add(&mut self, string: &str) { self.buffer.push_str(string); } pub fn children(&mut self) { for child in self...
code_fim
hard
{ "lang": "rust", "repo": "viddler-no/viddler-cli", "path": "/tools/log_server/src/comp.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let left = log_2(vistr.remaining.len() + 1); //let left = ((vistr.remaining.len() + 1) as f64).log2() as usize; (left, Some(left)) } fn vistr_next<T, D: DfsOrder>(vistr: Vistr<T, D>) -> (&T, Option<[Vistr<T, D>; 2]>) { let remaining = vistr.remaining; if remaining.len() == 1 { ...
code_fim
hard
{ "lang": "rust", "repo": "tiby312/compt", "path": "/src/dfs_order.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> vistr_dfs_level_remaining_hint(self) } ///Calls the closure in dfs preorder (root,left,right). ///Takes advantage of the callstack to do dfs. #[inline] fn dfs_inorder(self, mut func: impl FnMut(Self::Item)) { for a in self.remaining.iter() { func(a); ...
code_fim
hard
{ "lang": "rust", "repo": "tiby312/compt", "path": "/src/dfs_order.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tiby312/compt path: /src/dfs_order.rs use super::*; use alloc::boxed::Box; use core::marker::PhantomData; ///Specified which type of dfs order we want. In order/pre order/post order. trait DfsOrder: Clone { fn split_mut<T>(nodes: &mut [T]) -> (&mut T, &mut [T], &mut [T]); fn split<T>(no...
code_fim
hard
{ "lang": "rust", "repo": "tiby312/compt", "path": "/src/dfs_order.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let target_date = match from_clap::target_date(matches) { Some(date) => date, // Aribtrary choice: peeks back 6 months. None => (chrono::Local::now() - chrono::Duration::days(183)).date(), }; SqlOptions { expenditure_type: from_clap::expenditure_type(matches), ...
code_fim
hard
{ "lang": "rust", "repo": "j39m/katowice", "path": "/tangerine-tailleferre/src/main.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: j39m/katowice path: /tangerine-tailleferre/src/main.rs use std::os::unix::process::CommandExt; use std::process::Command; // chrono needs this to call Local.datetime_from_str(). use chrono::offset::TimeZone; const SQLITE3: &'static str = "/usr/bin/sqlite3"; const DB_PATH: &'static str = "/home...
code_fim
hard
{ "lang": "rust", "repo": "j39m/katowice", "path": "/tangerine-tailleferre/src/main.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>fn build_show_command(options: SqlOptions) -> String { let wordy_display_command = format!( r#"select {} from {} where date >= date("{}");"#, "*", expenditure_type_name_from_enum(&options.expenditure_type), options.target_date.format("%Y-%m-%d").to_string() ); l...
code_fim
hard
{ "lang": "rust", "repo": "j39m/katowice", "path": "/tangerine-tailleferre/src/main.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: tmartinfr/rust_employee_manager path: /src/main.rs use std::io::{self, Write}; mod employee_book; use employee_book::EmployeeBook; fn main() { let mut book = EmployeeBook::new(); println!( "\ Welcome, allowed commands are:\n\ > Add <employeename> to <departmen...
code_fim
hard
{ "lang": "rust", "repo": "tmartinfr/rust_employee_manager", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> match args.len() { 0 => return book.list_all(), 1 => return book.list_employee_from_department(args[0]), _ => return String::from("Invalid number of arguments to List command"), } }<|fim_prefix|>// repo: tmartinfr/rust_employee_manager path: /src/main.rs use std::io::{self...
code_fim
medium
{ "lang": "rust", "repo": "tmartinfr/rust_employee_manager", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>extern crate crypto; extern crate byteorder; extern crate base32; pub mod hotp; pub mod totp; pub use hotp::HOTP; pub use totp::TOTP;<|fim_prefix|>// repo: aoprisan/otpauth-rs path: /src/lib.rs //! Two-step verification of HOTP/TOTP. //! //! # Installation //! //! Add it to your ``Cargo.toml``: //! //!...
code_fim
hard
{ "lang": "rust", "repo": "aoprisan/otpauth-rs", "path": "/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: aoprisan/otpauth-rs path: /src/lib.rs //! Two-step verification of HOTP/TOTP. //! //! # Installation //! //! Add it to your ``Cargo.toml``: //! //! ```toml //! [dependencies] //! otpauth = "0.2" //! ``` //! //! Add ``extern crate otpauth`` to your crate root and your're good to go! //! //! # Exa...
code_fim
hard
{ "lang": "rust", "repo": "aoprisan/otpauth-rs", "path": "/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: yangpei11/RoadGraph-C- path: /rust/src/ArcRoad.rs use glm::{abs, int_bits_to_float_vec}; extern crate nalgebra_glm as glm; pub struct CArcRoad { pub points: Vec<glm::Vec2>, pub out_points:Vec<glm::Vec2>, } impl CArcRoad { pub fn New() -> CArcRoad { CArcRoad{ ...
code_fim
hard
{ "lang": "rust", "repo": "yangpei11/RoadGraph-C-", "path": "/rust/src/ArcRoad.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> //生成ArcRoad样条 pub fn generatePoints(&mut self, inputPoints:&Vec<glm::Vec2>) -> &Vec<glm::Vec2> { self.filter_points(&inputPoints); if inputPoints.len() == 2 { //let tmp = inputPoints; return &self.points; } else { ...
code_fim
hard
{ "lang": "rust", "repo": "yangpei11/RoadGraph-C-", "path": "/rust/src/ArcRoad.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ugnom/programming_competition_archive path: /abc/abc083/c.rs fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).<|fim_suffix|>rap()).collect(); let mut x = v[0]; let y = v[1]; let mut ans = 0; while x <= y { ans += 1; x *= 2; } ...
code_fim
medium
{ "lang": "rust", "repo": "ugnom/programming_competition_archive", "path": "/abc/abc083/c.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while x <= y { ans += 1; x *= 2; } println!("{}", ans); }<|fim_prefix|>// repo: ugnom/programming_competition_archive path: /abc/abc083/c.rs fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let v : Vec<i64> = s.trim().split_whitespace()...
code_fim
medium
{ "lang": "rust", "repo": "ugnom/programming_competition_archive", "path": "/abc/abc083/c.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // If not crossed-out, then prime.. for y in x * x..n { // Cross-out all multiples of i from i*i to n. These are non-prime if y % x == 0 { skip.push(y); } } } println!("Final list of primes is {:?}", primes); return pr...
code_fim
hard
{ "lang": "rust", "repo": "vsoch/learning-rust", "path": "/functions/src/games.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: vsoch/learning-rust path: /functions/src/games.rs // games.rs /// Find all prime numbers less than n. pub fn sieve(n: u32) -> Vec<u32> { let mut skip = vec![]; let mut primes = vec![]; println!("Starting number for sieve is {}", n); // If the number is less than 2, just return...
code_fim
hard
{ "lang": "rust", "repo": "vsoch/learning-rust", "path": "/functions/src/games.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: U007D/k210_pac path: /src/i2s0/channel/ror.rs #[doc = "Reader of register ror"] pub type R = crate::R<u32, super::ROR>; #[doc = "Reader of field `rx<|fim_suffix|>X FIFO data overrun interrupt. 0x0 for RX FIFO write valid, 0x1 for RX FIFO write overrun"] #[inline(always)] pub fn rxcho(&se...
code_fim
medium
{ "lang": "rust", "repo": "U007D/k210_pac", "path": "/src/i2s0/channel/ror.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>ne(always)] pub fn rxcho(&self) -> RXCHO_R { RXCHO_R::new((self.bits & 0x01) != 0) } }<|fim_prefix|>// repo: U007D/k210_pac path: /src/i2s0/channel/ror.rs #[doc = "Reader of register ror"] pub type R = crate::R<u32, super::ROR>; #[doc = "Reader of field `rx<|fim_middle|>cho`"] pub type RX...
code_fim
hard
{ "lang": "rust", "repo": "U007D/k210_pac", "path": "/src/i2s0/channel/ror.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl IOHIDManager { pub fn new() -> Option<Self> { let m = unsafe { IOHIDManagerCreate(kCFAllocatorDefault, IOHIDManagerOptions::kIOHIDManagerOptionNone as IOOptionBits) }; if m.is_null() { None } else { ...
code_fim
medium
{ "lang": "rust", "repo": "sibsibsib/iokit-rs", "path": "/iokit/src/hid/manager.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: sibsibsib/iokit-rs path: /iokit/src/hid/manager.rs use core_foundation::base::{CFRelease, TCFType, kCFAllocatorDefault}; pub use iokit_sys::hid::manager::*; use iokit_sys::types::IOOptionBits; <|fim_suffix|> unsafe { CFRelease(self.as_CFTypeRef()) } } } impl IOHIDManager { pub ...
code_fim
medium
{ "lang": "rust", "repo": "sibsibsib/iokit-rs", "path": "/iokit/src/hid/manager.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: firecracker-microvm/micro-http path: /src/request.rs e byte slice is expected to have the following format: </br> /// * Request Line: "GET SP Request-uri SP HTTP/1.0 CRLF" - Mandatory </br> /// * Request Headers "<headers> CRLF"- Optional </br> /// * Empty Line "CRLF" </b...
code_fim
hard
{ "lang": "rust", "repo": "firecracker-microvm/micro-http", "path": "/src/request.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: firecracker-microvm/micro-http path: /src/request.rs alformed. /// /// # Errors /// `InvalidHttpMethod` is returned if the specified HTTP method is unsupported. /// `InvalidHttpVersion` is returned if the specified HTTP version is unsupported. /// `InvalidUri` is returned if ...
code_fim
hard
{ "lang": "rust", "repo": "firecracker-microvm/micro-http", "path": "/src/request.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> // Test for invalid Request (length is less than minimum). let request_bytes = b"GET"; assert_eq!( Request::try_from(request_bytes, None).unwrap_err(), RequestError::InvalidRequest ); // Test for invalid Request (`GET` requests should have n...
code_fim
hard
{ "lang": "rust", "repo": "firecracker-microvm/micro-http", "path": "/src/request.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: cedric-h/donuts path: /src/math.rs use macroquad::prelude::{vec2, Vec2}; pub fn vec_to_angle(dir: Vec2) -> f32 { dir.y().atan2(dir.x()) } pub fn angle_to_vec(angle: f32) -> Vec2 { let (y, x) = angle.sin_cos(); vec2(x, y) } pub fn lerp(a: f32, b: f32, t: f32) -> f32 { a + (b - a...
code_fim
hard
{ "lang": "rust", "repo": "cedric-h/donuts", "path": "/src/math.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let f0 = t * (1.0 + ts[0] * (1.0 + ts[1] * (1.0 + ts[2] * (1.0 + ts[3] * (1.0 ...
code_fim
hard
{ "lang": "rust", "repo": "cedric-h/donuts", "path": "/src/math.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let xm1 = q0.dot(q1) - 1.0; let d = 1.0 - t; let t_pow2 = t * t; let d_pow2 = d * d; let mut ts = [0.0; 8]; let mut ds = [0.0; 8]; for i in (0..7).rev() { ts[i] = (U[i] * t_pow2 - V[i]) * xm1; ds[i] = (U[i] * d_pow2 - V[i]) * xm1; } let f0 = t ...
code_fim
hard
{ "lang": "rust", "repo": "cedric-h/donuts", "path": "/src/math.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> game.play(); assert_eq!(game.board, VecDeque::from(vec![3, 0, 2, 1])); game.play(); assert_eq!(game.board, VecDeque::from(vec![4, 2, 1, 3, 0])); } #[test] fn test_cycle() { let mut board = VecDeque::from(vec![5, 6, 7, 8]); cycle_clockwise(&mut...
code_fim
hard
{ "lang": "rust", "repo": "MichaelAquilina/adventofcode2018", "path": "/day09/src/game.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: MichaelAquilina/adventofcode2018 path: /day09/src/game.rs use std::collections::{HashMap, VecDeque}; use crate::config::Config; #[derive(Debug)] pub struct Game { config: Config, board: VecDeque<u32>, scores: HashMap<u32, u32>, current_index: usize, current_player: u32, ...
code_fim
hard
{ "lang": "rust", "repo": "MichaelAquilina/adventofcode2018", "path": "/day09/src/game.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut board = VecDeque::from(vec![5, 6, 7, 8]); cycle_clockwise(&mut board); let expected = VecDeque::from(vec![6, 7, 8, 5]); assert_eq!(board, expected); cycle_anticlockwise(&mut board); let expected = VecDeque::from(vec![5, 6, 7, 8]); asser...
code_fim
hard
{ "lang": "rust", "repo": "MichaelAquilina/adventofcode2018", "path": "/day09/src/game.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_str_len() { assert_eq!(2 + 2, 4); } #[actix_rt::test] async fn test_create_todos() { let pool = init_pool("").expect("Failed to create pool"); let mut app = test::init_service( App::new() .data(AppState { ...
code_fim
hard
{ "lang": "rust", "repo": "DanielCardonaRojas/actix-todolist", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DanielCardonaRojas/actix-todolist path: /src/main.rs use actix_web::{web, App, HttpServer}; mod app_state; mod db_connection; mod graphql; mod handlers; mod middlewares; mod models; mod services; pub mod schema; use dotenv::dotenv; #[macro_use] extern crate diesel; extern crate bcrypt; extern c...
code_fim
hard
{ "lang": "rust", "repo": "DanielCardonaRojas/actix-todolist", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jwarwick/aoc_2018 path: /day01/src/main.rs extern crate day01; extern crate util; <|fim_suffix|> let result = day01::duplicate_from_file(&filename); println!("Part 2 Result: {}", result); }<|fim_middle|>fn main() { let filename = util::get_argument("input.txt"); println!("Using f...
code_fim
hard
{ "lang": "rust", "repo": "jwarwick/aoc_2018", "path": "/day01/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let filename = util::get_argument("input.txt"); println!("Using file: {}", filename); let result = day01::calibrate_from_file(&filename); println!("Part 1 Result: {}", result); let result = day01::duplicate_from_file(&filename); println!("Part 2 Result: {}", result); }<|fim_prefi...
code_fim
easy
{ "lang": "rust", "repo": "jwarwick/aoc_2018", "path": "/day01/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let result = day01::duplicate_from_file(&filename); println!("Part 2 Result: {}", result); }<|fim_prefix|>// repo: jwarwick/aoc_2018 path: /day01/src/main.rs extern crate day01; extern crate util; fn main() { let filename = util::get_argument("input.txt"); println!("Using file: {}", file...
code_fim
medium
{ "lang": "rust", "repo": "jwarwick/aoc_2018", "path": "/day01/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `MPUSEGB215` writer - MPU Segment Border 2 Bit: 15"] pub struct MPUSEGB215_W<'a> { w: &'a mut W, } impl<'a> MPUSEGB215_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc ...
code_fim
hard
{ "lang": "rust", "repo": "chrismolli/msp430fr6972", "path": "/src/mpu/mpusegb2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &self.0 } } #[doc = "Field `MPUSEGB213` writer - MPU Segment Border 2 Bit: 13"] pub struct MPUSEGB213_W<'a> { w: &'a mut W, } impl<'a> MPUSEGB213_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc ...
code_fim
hard
{ "lang": "rust", "repo": "chrismolli/msp430fr6972", "path": "/src/mpu/mpusegb2.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chrismolli/msp430fr6972 path: /src/mpu/mpusegb2.rs ::FieldReader<bool, bool>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } #[doc = "Field `MPUSEGB24` writer - MPU Segment Border 2 Bit: 4"] pub struct MPUSEGB24_W<'a> { w: &'a mut W, } impl<'a> MPUSEGB24...
code_fim
hard
{ "lang": "rust", "repo": "chrismolli/msp430fr6972", "path": "/src/mpu/mpusegb2.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>fn ptr_arith_offset() { let v = [1i16, 2]; let x = &v as *const [i16] as *const i16; let x = x.wrapping_offset(1); assert_eq!(unsafe { *x }, 2); } fn ptr_arith_offset_overflow() { let v = [1i16, 2]; let x = &mut ptr::null(); // going through memory as there are more sanity checks ...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/miri", "path": "/tests/pass/ptr_offset.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-lang/miri path: /tests/pass/ptr_offset.rs //@compile-flags: -Zmiri-permissive-provenance #![feature(ptr_sub_ptr)] use std::{mem, ptr}; fn main() { smoke(); test_offset_from(); test_vec_into_iter(); ptr_arith_offset(); ptr_arith_offset_overflow(); ptr_offset(); } fn...
code_fim
hard
{ "lang": "rust", "repo": "rust-lang/miri", "path": "/tests/pass/ptr_offset.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>; fn get_sync_state_with_metrics(token: &str); }<|fim_prefix|>// repo: suhanyujie/siwei-note path: /src/sdk/note_store.rs /// 印象笔记中对笔记本的操作都是基于 [NoteStore](https://dev.yinxiang.com/doc/articles/creating_notes.php) pub trait <|fim_middle|>NoteStoreTrait { fn get_sync_state(token: &str)
code_fim
easy
{ "lang": "rust", "repo": "suhanyujie/siwei-note", "path": "/src/sdk/note_store.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: suhanyujie/siwei-note path: /src/sdk/note_store.rs /// 印象笔记中对笔记本的操作都是基于 [NoteStore](https://dev.yinxi<|fim_suffix|>NoteStoreTrait { fn get_sync_state(token: &str); fn get_sync_state_with_metrics(token: &str); }<|fim_middle|>ang.com/doc/articles/creating_notes.php) pub trait
code_fim
easy
{ "lang": "rust", "repo": "suhanyujie/siwei-note", "path": "/src/sdk/note_store.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn clear(&mut self) { self.browser_handle = ::std::option::Option::None; self.url = ::std::option::Option::None; self.referrer = ::std::option::Option::None; self.special_fields.clear(); } fn default_instance() -> &'static CMsgOpenSteamURL { static inst...
code_fim
hard
{ "lang": "rust", "repo": "icewind1991/steam-vent", "path": "/protobuf/src/generated/htmlmessages.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fn new() -> CHistoryEntry { CHistoryEntry::new() } fn clear(&mut self) { self.url = ::std::option::Option::None; self.special_fields.clear(); } fn default_instance() -> &'static CHistoryEntry { static instance: CHistoryEntry = CHistoryEntry { ...
code_fim
hard
{ "lang": "rust", "repo": "icewind1991/steam-vent", "path": "/protobuf/src/generated/htmlmessages.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: icewind1991/steam-vent path: /protobuf/src/generated/htmlmessages.rs owser_handle: ::std::option::Option<u32>, // @@protoc_insertion_point(field:CMsgMouseUp.mouse_button) pub mouse_button: ::std::option::Option<u32>, // @@protoc_insertion_point(field:CMsgMouseUp.modifiers) pub mo...
code_fim
hard
{ "lang": "rust", "repo": "icewind1991/steam-vent", "path": "/protobuf/src/generated/htmlmessages.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if is_important { write!(f, "<strong>")?; } write!(f, "{text}")?; if is_important { write!(f, "</strong>")?; } writeln!(f, "</{tag}>")?; // Print attributes { ...
code_fim
hard
{ "lang": "rust", "repo": "rsaarelm/otlbook", "path": "/webserver/src/html.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rsaarelm/otlbook path: /webserver/src/html.rs use std::{fmt, str::FromStr}; use base::{Section, Uri}; /// Display a value as HTML. pub trait HtmlFmt { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result; } /// Wrapper type for HTML-formatted display. #[derive(Debug)] pub struct Html<...
code_fim
hard
{ "lang": "rust", "repo": "rsaarelm/otlbook", "path": "/webserver/src/html.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> write(self, "h1", f) } } impl HtmlFmt for Uri { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Uri::Http(s) => { const MAX_DISPLAYED_URL_LEN: usize = 75; write!(f, "<a href='{s}'>")?; if s.len() >...
code_fim
hard
{ "lang": "rust", "repo": "rsaarelm/otlbook", "path": "/webserver/src/html.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: bobbin-rs/bobbin-sdk path: /mcu/bobbin-kinetis/k64/src/ext/flash.rs use ftfe::*; use bobbin_hal::flash::*; pub trait FlashBusy { fn flash_busy(&self) -> bool; } impl FlashBusy for FtfePeriph { fn flash_busy(&self) -> bool { !self.fstat().test_ccif() } } pub trait FtfeWrite...
code_fim
hard
{ "lang": "rust", "repo": "bobbin-rs/bobbin-sdk", "path": "/mcu/bobbin-kinetis/k64/src/ext/flash.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>impl FlashErase for FtfePeriph { fn erase_start(&self, addr: *mut u8) -> Result<(), FlashError> { let addr = addr as u32; self.write_command(&[ (addr >> 0) as u8, (addr >> 8) as u8, (addr >> 16) as u8, 0x08, ]); Ok(()) ...
code_fim
hard
{ "lang": "rust", "repo": "bobbin-rs/bobbin-sdk", "path": "/mcu/bobbin-kinetis/k64/src/ext/flash.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let addr = addr as u32; self.write_command(&[ (addr >> 0) as u8, (addr >> 8) as u8, (addr >> 16) as u8, 0x08, ]); Ok(()) } fn erase_complete(&self) -> bool { !self.flash_busy() } } /// Write bytes to flas...
code_fim
hard
{ "lang": "rust", "repo": "bobbin-rs/bobbin-sdk", "path": "/mcu/bobbin-kinetis/k64/src/ext/flash.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gnzlbg/stdsimd path: /coresimd/src/x86/i686/ssse3.rs //! Supplemental Streaming SIMD Extensions 3 (SSSE3) #[cfg(test)] use stdsimd_test::assert_instr; use x86::*; /// Compute the absolute value of packed 8-bit integers in `a` and /// return the unsigned results. #[inline] #[target_feature(ena...
code_fim
hard
{ "lang": "rust", "repo": "gnzlbg/stdsimd", "path": "/coresimd/src/x86/i686/ssse3.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> #[simd_test = "ssse3,mmx"] unsafe fn test_mm_hadd_pi16() { let a = _mm_setr_pi16(1, 2, 3, 4); let b = _mm_setr_pi16(4, 128, 4, 3); let expected = _mm_setr_pi16(3, 7, 132, 7); let r = _mm_hadd_pi16(a, b); assert_eq_m64(r, expected); } #[simd_test = "...
code_fim
hard
{ "lang": "rust", "repo": "gnzlbg/stdsimd", "path": "/coresimd/src/x86/i686/ssse3.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> j -= 1; } } while j > 0{ a[len] = b[j-1]; len -= 1; j -= 1; } } }<|fim_prefix|>// repo: ScarboroughCoral/Notes path: /程序员面试金典/面试题 10.01. 合并排序的数组.rs impl Solution { pub fn merge(a: &mut Vec<i32>, m: i32, b: &mut Vec<i32>, n: i3...
code_fim
hard
{ "lang": "rust", "repo": "ScarboroughCoral/Notes", "path": "/程序员面试金典/面试题 10.01. 合并排序的数组.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ScarboroughCoral/Notes path: /程序员面试金典/面试题 10.01. 合并排序的数组.rs impl Solution { pub fn merge(a: &mut Vec<i32>, m: i32, b: &mut Vec<i32>, n: i32) { let mut len = (m + n - 1) as usize; let mut i = m as usize; let mut j = n as usize; while i > 0 && j > 0{ ...
code_fim
hard
{ "lang": "rust", "repo": "ScarboroughCoral/Notes", "path": "/程序员面试金典/面试题 10.01. 合并排序的数组.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: fedecalendino/adventofcode path: /src/day01.rs use std::fs::read_to_string; fn read(name: &str) -> Vec<Option<i32>> { let path = format!("./files/{name}.txt", name = name); let mut values = Vec::new(); for line in read_to_string(path).unwrap().lines() { // add options to s...
code_fim
medium
{ "lang": "rust", "repo": "fedecalendino/adventofcode", "path": "/src/day01.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for each in values.iter() { match each { Some(value) => elf += value, None => { if elf > max { max = elf; } elf = 0; } } } max } fn part02(input: &str) -> i32 { let va...
code_fim
hard
{ "lang": "rust", "repo": "fedecalendino/adventofcode", "path": "/src/day01.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert_eq!(part01("day01/test01"), 24000); // ⭐ println!("Day 01 - Part 01 = {}", part01("day01/input")); assert_eq!(part02("day01/test01"), 45000); // ⭐ println!("Day 01 - Part 02 = {}", part02("day01/input")); }<|fim_prefix|>// repo: fedecalendino/adventofcode path: /src/day01.rs use s...
code_fim
hard
{ "lang": "rust", "repo": "fedecalendino/adventofcode", "path": "/src/day01.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: async-email/async-smtp path: /src/error.rs //! Error and result type for SMTP clients use self::Error::*; use crate::response::{Response, Severity}; use base64::DecodeError; use std::io; use std::net::AddrParseError; use std::string::FromUtf8Error; /// An enum of all error kinds. #[derive(this...
code_fim
hard
{ "lang": "rust", "repo": "async-email/async-smtp", "path": "/src/error.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> let err = Error::Permanent(Response::new( Code::new( Severity::PermanentNegativeCompletion, Category::Information, Detail::Zero, ), vec![ "gmx.net (mxgmx117) Nemesis ESMTP Service not available".to_...
code_fim
hard
{ "lang": "rust", "repo": "async-email/async-smtp", "path": "/src/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match response.code.severity { Severity::TransientNegativeCompletion => Transient(response), Severity::PermanentNegativeCompletion => Permanent(response), _ => Client("Unknown error code"), } } } impl From<&'static str> for Error { fn from(strin...
code_fim
hard
{ "lang": "rust", "repo": "async-email/async-smtp", "path": "/src/error.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>FO_1_4 => 4, TXIFLSELW::TXFIFO_1_2 => 5, TXIFLSELW::TXFIFO_3_4 => 6, } } } #[doc = r" Proxy"] pub struct _TXIFLSELW<'a> { w: &'a mut W, } impl<'a> _TXIFLSELW<'a> { #[doc = r" Writes `variant` to the field"] #[inline] pub fn variant(self, variant: TXIFLSE...
code_fim
hard
{ "lang": "rust", "repo": "alistairbill/bluenrg1", "path": "/src/uart/ifls.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: alistairbill/bluenrg1 path: /src/uart/ifls.rs #[doc = r" Value read from the register"] pub struct R { bits: u8, } #[doc = r" Value to write to the register"] pub struct W { bits: u8, } impl super::IFLS { #[doc = r" Modifies the contents of the register"] #[inline] pub fn mod...
code_fim
hard
{ "lang": "rust", "repo": "alistairbill/bluenrg1", "path": "/src/uart/ifls.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> pub const SIGNAL_SEGV: Signal = Signal(11); pub const SIGNAL_USR2: Signal = Signal(12); pub const SIGNAL_PIPE: Signal = Signal(13); pub const SIGNAL_ALRM: Signal = Signal(14); pub const SIGNAL_TERM: Signal = Signal(15); pub const SIGNAL_CHLD: Signal = Signal(16); pub const SIGNAL_CONT: Signal...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/wasi/src/lib_generated.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: marco-c/gecko-dev-comments-removed path: /third_party/rust/wasi/src/lib_generated.rs 10 => "BUSY", 11 => "CANCELED", 12 => "CHILD", 13 => "CONNABORTED", 14 => "CONNREFUSED", 15 => "CONNRESET", 16 => "DEADLK", ...
code_fim
hard
{ "lang": "rust", "repo": "marco-c/gecko-dev-comments-removed", "path": "/third_party/rust/wasi/src/lib_generated.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }