text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: SINHASantos/wasmer path: /lib/wasi/src/state/builder.rs
ationError>
where
F: Fn(&mut PreopenDirBuilder) -> &mut PreopenDirBuilder,
{
self.add_preopen_build(inner)?;
Ok(self)
}
/// Preopen a directory and configure it.
///
/// Usage:
///
//... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/wasmer",
"path": "/lib/wasi/src/state/builder.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SINHASantos/wasmer path: /lib/wasi/src/state/builder.rs
ateCreationError {
#[error("bad environment variable format: `{0}`")]
EnvironmentVariableFormatError(String),
#[error("argument contains null byte: `{0}`")]
ArgumentContainsNulByte(String),
#[error("preopened directory n... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/wasmer",
"path": "/lib/wasi/src/state/builder.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Determine the STDIN
let stdin: Box<dyn VirtualFile + Send + Sync + 'static> = self
.stdin
.take()
.unwrap_or_else(|| Box::new(ArcFile::new(Box::new(super::Stdin::default()))));
let fs_backing = self
.fs
.take()
... | code_fim | hard | {
"lang": "rust",
"repo": "SINHASantos/wasmer",
"path": "/lib/wasi/src/state/builder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VisionistInc/advent-of-code-2020 path: /cicavey/07/src/main.rs
use regex::Regex;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::Path;
use std::collections::HashMap;
fn lines_from_file(filename: impl AsRef<Path>) -> Vec<String> {
let file = File::open(filename).expect("... | code_fim | hard | {
"lang": "rust",
"repo": "VisionistInc/advent-of-code-2020",
"path": "/cicavey/07/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let es = entry.to_string();
let ev: Vec<&str> = es.splitn(2, ' ').collect();
let bag_count = ev.get(0).unwrap().parse::<usize>().unwrap();
let bag_type = ev.get(1).unwrap().to_string();
children.insert(bag_type, bag_count);
}
m... | code_fim | hard | {
"lang": "rust",
"repo": "VisionistInc/advent-of-code-2020",
"path": "/cicavey/07/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if entry == "no other" {
continue
}
let es = entry.to_string();
let ev: Vec<&str> = es.splitn(2, ' ').collect();
let bag_count = ev.get(0).unwrap().parse::<usize>().unwrap();
let bag_type = ev.get(1).unwrap().to_stri... | code_fim | hard | {
"lang": "rust",
"repo": "VisionistInc/advent-of-code-2020",
"path": "/cicavey/07/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ssions::Permissions;
pub use user::User;<|fim_prefix|>// repo: yo-main/akingbee path: /cerbes/src/domain/entities/mod.rs
mod credentials;
mod jwt;
mod permissio<|fim_middle|>ns;
mod user;
pub use credentials::Credentials;
pub use jwt::Jwt;
pub use permi | code_fim | medium | {
"lang": "rust",
"repo": "yo-main/akingbee",
"path": "/cerbes/src/domain/entities/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yo-main/akingbee path: /cerbes/src/domain/entities/mod.rs
mod credentials;
mod jwt;
mod permissio<|fim_suffix|>ssions::Permissions;
pub use user::User;<|fim_middle|>ns;
mod user;
pub use credentials::Credentials;
pub use jwt::Jwt;
pub use permi | code_fim | medium | {
"lang": "rust",
"repo": "yo-main/akingbee",
"path": "/cerbes/src/domain/entities/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>entials;
pub use jwt::Jwt;
pub use permissions::Permissions;
pub use user::User;<|fim_prefix|>// repo: yo-main/akingbee path: /cerbes/src/domain/entities/mod.rs
mod credentials;
mod jwt;
mod permissio<|fim_middle|>ns;
mod user;
pub use credentials::Cred | code_fim | easy | {
"lang": "rust",
"repo": "yo-main/akingbee",
"path": "/cerbes/src/domain/entities/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeaye/ncurses-rs path: /examples/ex_6.rs
/*
Copyright © 2013 Free Software Foundation, Inc
See licensing in LICENSE file
File: examples/ex_6.rs
Author: Jesse 'Jeaye' Wilkerson
Description:
Extension of ex_3 that adds naive syntax
highlighting to showcase attribut... | code_fim | hard | {
"lang": "rust",
"repo": "jeaye/ncurses-rs",
"path": "/examples/ex_6.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /* Read until we hit a word delimiter. */
while !WORD_LIMITS.contains(&ch)
{
s.push(ch);
ch = self.file_reader.next().unwrap().ok().expect("Unable to read byte");
}
/* Return the word string and the terminating delimiter. */
match char::from_u32(ch as u32)
{
... | code_fim | hard | {
"lang": "rust",
"repo": "jeaye/ncurses-rs",
"path": "/examples/ex_6.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /* Read the whole file. */
while pager.file_reader.peek().is_some()
{
/* Read a word at a time. */
let (word, leftover) = pager.read_word();
let attr = pager.highlight_word(word.as_ref());
let leftover_attr = pager.highlight_word(format!("{}", leftover).as_ref());
/* Get the cur... | code_fim | hard | {
"lang": "rust",
"repo": "jeaye/ncurses-rs",
"path": "/examples/ex_6.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Riuchando/projectEuler path: /rust/src/problem009.rs
use std::vec::Vec;
fn pythagorean_triplets(limit: u32) -> Vec<(u32, u32, u32)> {
<|fim_suffix|> match triplets.iter().find(|(a, b, c)| a + b + c == 1000) {
Some((a, b, c)) => a * b * c,
None => 0,
}
}<|fim_middle|> l... | code_fim | hard | {
"lang": "rust",
"repo": "Riuchando/projectEuler",
"path": "/rust/src/problem009.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match triplets.iter().find(|(a, b, c)| a + b + c == 1000) {
Some((a, b, c)) => a * b * c,
None => 0,
}
}<|fim_prefix|>// repo: Riuchando/projectEuler path: /rust/src/problem009.rs
use std::vec::Vec;
fn pythagorean_triplets(limit: u32) -> Vec<(u32, u32, u32)> {
<|fim_middle|> l... | code_fim | hard | {
"lang": "rust",
"repo": "Riuchando/projectEuler",
"path": "/rust/src/problem009.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DevinR528/matrix-p2p-client path: /src/matrix_client.rs
use std::sync::Arc;
use async_trait::async_trait;
use http::{Method as HttpMethod, Request, Response};
use matrix_sdk::{Error as MatrixError, HttpClient, Result as MatrixResult, Session};
use ruma::identifiers::{DeviceId, UserId};
use toki... | code_fim | hard | {
"lang": "rust",
"repo": "DevinR528/matrix-p2p-client",
"path": "/src/matrix_client.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[async_trait]
impl HttpClient for P2PClient {
/// The method abstracting sending request types and receiving response types.
async fn send_request(
&self,
_requires_auth: bool,
_homeserver: &Url,
_session: &Arc<RwLock<Option<Session>>>,
_method: HttpMethod,... | code_fim | hard | {
"lang": "rust",
"repo": "DevinR528/matrix-p2p-client",
"path": "/src/matrix_client.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: code0xff/ufc-appbase path: /src/libs/callback.rs
use appbase::channel;
use appbase::channel::Sender;
use serde_json::{Map, Value};
use crate::error::error::ExpectedError;
use crate::libs;
use crate::libs::serde::select_value;
use crate::plugin::mongo::MongoMsg;
use crate::plugin::mysql::MySqlMs... | code_fim | hard | {
"lang": "rust",
"repo": "code0xff/ufc-appbase",
"path": "/src/libs/callback.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn mysql_send(mysql_channel: &channel::Sender, schema: &Schema, values: &Map<String, Value>) -> Result<(), ExpectedError> {
let insert_query = schema.insert_query.clone();
let names: Vec<&str> = schema.attributes.iter().map(|attribute| { attribute.name.as_str() }).collect();
let selected_value... | code_fim | hard | {
"lang": "rust",
"repo": "code0xff/ufc-appbase",
"path": "/src/libs/callback.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let insert_query = schema.insert_query.clone();
let names: Vec<&str> = schema.attributes.iter().map(|attribute| { attribute.name.as_str() }).collect();
let selected_value = select_value(values, names)?;
let mysql_msg = MySqlMsg::new(insert_query, Value::Object(selected_value));
let _ =... | code_fim | hard | {
"lang": "rust",
"repo": "code0xff/ufc-appbase",
"path": "/src/libs/callback.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xCrypt0r/Baekjoon path: /src/15/15547.rs
/**
* 15547. Lorem ipsum
*
* 작성자: xCrypt0r
* 언어: Rust 2018
* 사용 메모리: 13,032 KB
* 소요 시간: 4 ms
* 해결 날짜: 2020년 10월 8일
*/
macro_rules! get_line {
( $( $t: ty ),+ ) => {
{
let mut line = String::new();
<|fim_suffix|> ... | code_fim | medium | {
"lang": "rust",
"repo": "xCrypt0r/Baekjoon",
"path": "/src/15/15547.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let (a, b) = get_line!(usize, usize);
let data = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec quis lectus sit amet ante suscipit tempor. Aenean dapibus finibus tortor vitae facilisis. Nulla facilisi. Donec suscipit ante a sapien gravida eleifend. Curabitur in lectus ... | code_fim | medium | {
"lang": "rust",
"repo": "xCrypt0r/Baekjoon",
"path": "/src/15/15547.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Serialize for Node {
fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where
S: Serializer,
{
let mut node_ser = serializer.serialize_struct("Node", 3)?;
node_ser.serialize_field("url", self.url.as_str())?;
n... | code_fim | hard | {
"lang": "rust",
"repo": "joshmeranda/maxtract",
"path": "/src/node.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: joshmeranda/maxtract path: /src/node.rs
use std::{
cmp::Eq,
collections::BTreeSet,
hash::{Hash, Hasher},
str,
string::String,
};
use curl::easy::{Easy2, Handler, WriteError};
use regex::{Match, Regex};
use select::{document::Document, node::Node as DomNode, predicate::Name... | code_fim | hard | {
"lang": "rust",
"repo": "joshmeranda/maxtract",
"path": "/src/node.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match parser.parse(child) {
Ok(mut url) => {
url.set_fragment(None);
Ok(url)
}
Err(err) => Err(err),
}
}
}
impl Serialize for Node {
fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Se... | code_fim | hard | {
"lang": "rust",
"repo": "joshmeranda/maxtract",
"path": "/src/node.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>The system time of when the event was logged.
#[cfg_attr(feature = "serde", serde(with = "ts_milliseconds"))]
pub system_time: DateTime<Utc>,
}<|fim_prefix|>// repo: grapl-security/grapl path: /src/rust/sysmon-parser/src/system/time_created.rs
#[cfg(feature = "serde")]
use chrono::serde::ts_milli... | code_fim | medium | {
"lang": "rust",
"repo": "grapl-security/grapl",
"path": "/src/rust/sysmon-parser/src/system/time_created.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: grapl-security/grapl path: /src/rust/sysmon-parser/src/system/time_created.rs
#[cfg(feature = "serde")]
use chrono::serde::ts_milliseconds;
use chrono::{
DateTime,
Utc,
};
/// The time stamp that identifies when the event was logged.
///
/// <https://docs.microsoft.com/en-us/windows/win... | code_fim | medium | {
"lang": "rust",
"repo": "grapl-security/grapl",
"path": "/src/rust/sysmon-parser/src/system/time_created.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vectorizer-labs/mqtt_5 path: /src/pingresp.rs
use super::data_representation::{
reserved_flags::ReservedFlags,
RemainingLength
};
<|fim_suffix|>#[derive(Clone, Debug, PartialEq, FromReader)]
pub struct Pingresp
(
ReservedFlags,
RemainingLength
);<|fim_middle|>use packattack::*;
... | code_fim | easy | {
"lang": "rust",
"repo": "vectorizer-labs/mqtt_5",
"path": "/src/pingresp.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Clone, Debug, PartialEq, FromReader)]
pub struct Pingresp
(
ReservedFlags,
RemainingLength
);<|fim_prefix|>// repo: vectorizer-labs/mqtt_5 path: /src/pingresp.rs
use super::data_representation::{
reserved_flags::ReservedFlags,
RemainingLength
};
<|fim_middle|>use packattack::*;
... | code_fim | easy | {
"lang": "rust",
"repo": "vectorizer-labs/mqtt_5",
"path": "/src/pingresp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod core;
mod helper;
mod middleware;
mod module;
mod config;
mod schema;
#[actix_rt::main]
async fn main() -> std::io::Result<()> {
server().await
}<|fim_prefix|>// repo: coderBuffalo/rust-actix-demo path: /src/main.rs
#[macro_use]
extern crate diesel;
#[macro_use]
extern crate lazy_static;
#[macro... | code_fim | easy | {
"lang": "rust",
"repo": "coderBuffalo/rust-actix-demo",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[actix_rt::main]
async fn main() -> std::io::Result<()> {
server().await
}<|fim_prefix|>// repo: coderBuffalo/rust-actix-demo path: /src/main.rs
#[macro_use]
extern crate diesel;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate redis_async;
#[macro_use]
extern crate serde_derive;
#[m... | code_fim | medium | {
"lang": "rust",
"repo": "coderBuffalo/rust-actix-demo",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: coderBuffalo/rust-actix-demo path: /src/main.rs
#[macro_use]
extern crate diesel;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate redis_async;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate validator_derive;
<|fim_suffix|>#[actix_rt::main]
async fn main() -> ... | code_fim | medium | {
"lang": "rust",
"repo": "coderBuffalo/rust-actix-demo",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn it_works() {
println!("{:?}", Solution::permute(vec![1, 2, 3]));
}
}<|fim_prefix|>// repo: y-usuzumi/survive-the-course path: /leetcode-cn/46.全排列/permutations/src/lib.rs
struct Solution;
impl Solution {
pub fn permute(nums: Vec<i32>) -> Vec<Vec<i32>> {
if nums.... | code_fim | medium | {
"lang": "rust",
"repo": "y-usuzumi/survive-the-course",
"path": "/leetcode-cn/46.全排列/permutations/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: y-usuzumi/survive-the-course path: /leetcode-cn/46.全排列/permutations/src/lib.rs
struct Solution;
impl Solution {
pub fn permute(nums: Vec<i32>) -> Vec<Vec<i32>> {
if nums.len() == 0 {
return vec![];
}
if nums.len() == 1 {
return vec![nums];
... | code_fim | medium | {
"lang": "rust",
"repo": "y-usuzumi/survive-the-course",
"path": "/leetcode-cn/46.全排列/permutations/src/lib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fiberseq/fibertools-rs path: /py-ft/src/fiberdata.rs
use fibertools_rs::fiber::FiberseqData;
use pyo3::iter::IterNextOutput;
use pyo3::prelude::*;
use rust_htslib::{bam, bam::ext::BamRecordExtensions, bam::record::Aux, bam::Read};
use std::time;
use std::vec::IntoIter;
#[pyclass]
/// Class for ... | code_fim | hard | {
"lang": "rust",
"repo": "fiberseq/fibertools-rs",
"path": "/py-ft/src/fiberdata.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> log::info!(
"{} records fetched in {:.2}s",
records.len(),
self._time_from_last()
);
let fiberdata = FiberseqData::from_records(records, &head_view, 0);
log::info!(
"Fiberdata made for {} records in {:.2}s",
fiberd... | code_fim | hard | {
"lang": "rust",
"repo": "fiberseq/fibertools-rs",
"path": "/py-ft/src/fiberdata.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Asm6502, Debug, PartialEq)]
#[asm6502(relative = 0xB0)]
pub struct BCS(AddressMode);
#[derive(Asm6502, Debug, PartialEq)]
#[asm6502(relative = 0xF0)]
pub struct BEQ(AddressMode);
#[derive(Asm6502, Debug, PartialEq)]
#[asm6502(zero = 0x24, absolute = 0x2C)]
pub struct BIT(AddressMode);
#[derive... | code_fim | hard | {
"lang": "rust",
"repo": "fanzeyi/nestle",
"path": "/asm6502/src/instructions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fanzeyi/nestle path: /asm6502/src/instructions.rs
use asm6502_derive::Asm6502;
use enum_dispatch::enum_dispatch;
#[derive(Debug, PartialEq)]
pub enum AddressMode {
Implicit,
Accumulator,
Immediate(u8),
Zero(u8),
ZeroX(u8),
ZeroY(u8),
Relative(i8),
Absolute(u16),
... | code_fim | hard | {
"lang": "rust",
"repo": "fanzeyi/nestle",
"path": "/asm6502/src/instructions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Asm6502, Debug, PartialEq)]
#[asm6502(
immediate = 0xA2,
zero = 0xA6,
zero_y = 0xB6,
absolute = 0xAE,
absolute_y = 0xBE
)]
pub struct LDX(AddressMode);
#[derive(Asm6502, Debug, PartialEq)]
#[asm6502(
immediate = 0xA0,
zero = 0xA4,
zero_x = 0xB4,
absolute = 0xA... | code_fim | hard | {
"lang": "rust",
"repo": "fanzeyi/nestle",
"path": "/asm6502/src/instructions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match cli.subcommand() {
("server", Some(matches)) => {
let config = matches.value_of("config").unwrap();
let format = matches.value_of("format").unwrap();
if matches.is_present("detached") {
log::info!("detached");
let logfil... | code_fim | hard | {
"lang": "rust",
"repo": "FirelightFlagboy/taskmaster",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let cli = cli::generate();
let mut args = env::args();
init(&cli).unwrap();
match cli.subcommand() {
("server", Some(matches)) => {
let config = matches.value_of("config").unwrap();
let format = matches.value_of("format").unwrap();
if matches.is... | code_fim | hard | {
"lang": "rust",
"repo": "FirelightFlagboy/taskmaster",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FirelightFlagboy/taskmaster path: /src/main.rs
#![warn(clippy::all, clippy::pedantic)]
extern crate clap;
extern crate serde;
mod cli;
mod client;
mod server;
mod shared;
use log::{LevelFilter, SetLoggerError};
use nix::unistd::{close, execve, fork, setsid, ForkResult};
use shared::{
error... | code_fim | hard | {
"lang": "rust",
"repo": "FirelightFlagboy/taskmaster",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ben0x539/git-blame-everything path: /src/main.rs
#![feature(globs, macro_rules)]
extern crate libc;
use std::ptr;
use std::c_str::CString;
use std::finally::Finally;
use std::collections::HashMap;
use std::collections::hashmap;
use std::mem::transmute;
use std::sync;
use std::comm;
use libc::... | code_fim | hard | {
"lang": "rust",
"repo": "ben0x539/git-blame-everything",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(0, git_blame_get_hunk_count(blame)) {
let hunk = git_blame_get_hunk_byindex(blame, i);
let final_commit_id = (*hunk).final_commit_id;
let mut commit: *mut git_commit = ptr::null_mut();
if git_commit_lookup(&mut commit, repos, &final_commit_id) != GIT_OK ... | code_fim | hard | {
"lang": "rust",
"repo": "ben0x539/git-blame-everything",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Creates a room position from world coords.
///
/// # Panics
///
/// Panics if either x or y is out of the range `-128 * 50 .. +128 * 50`.
///
/// See [`Position::world_coords`].
#[inline]
pub fn from_world_coords(x: i32, y: i32) -> Self {
// not inclusive si... | code_fim | hard | {
"lang": "rust",
"repo": "smessmer/screeps-game-api",
"path": "/src/local/room_position/world_utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: smessmer/screeps-game-api path: /src/local/room_position/world_utils.rs
use super::{Position, HALF_WORLD_SIZE};
impl Position {
/// Returns this position's horizontal "world coordinate".
///
/// The value is equal to `50 * room_x + x`, where `room_x` is defined as
/// `room_x = ... | code_fim | hard | {
"lang": "rust",
"repo": "smessmer/screeps-game-api",
"path": "/src/local/room_position/world_utils.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Self::from_coords_and_world_coords_adjusted(x, y, room_x, room_y)
}
}
#[cfg(test)]
mod test {
use super::Position;
const TEST_ROOM_NAMES: &[&str] = &[
"E1N1", "E20N0", "W0N0", "E0N0", "W0S0", "E0S0", "W0N0", "E0N0", "W0S0", "E0S0", "W50S20",
"W127S127", "W127N127", "E... | code_fim | hard | {
"lang": "rust",
"repo": "smessmer/screeps-game-api",
"path": "/src/local/room_position/world_utils.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!("123", timer_for_harvest::parse_account_details("GET /?expires_in=123&scope=harvest%3A456").2);
assert_eq!("123", timer_for_harvest::parse_account_details("GET /?scope=harvest%3A456&expires_in=123").2);
}
}<|fim_prefix|>// repo: sftim/timer-for-harvest path: /tests/lib.rs
#... | code_fim | hard | {
"lang": "rust",
"repo": "sftim/timer-for-harvest",
"path": "/tests/lib.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sftim/timer-for-harvest path: /tests/lib.rs
#[cfg(test)]
mod test {
#[test]
fn should_convert_duration_correctly() {
assert_eq!("1:00", timer_for_harvest::f32_to_duration_str(1.0));
assert_eq!("0:01", timer_for_harvest::f32_to_duration_str(1.0 / 60.0));
assert_eq!... | code_fim | hard | {
"lang": "rust",
"repo": "sftim/timer-for-harvest",
"path": "/tests/lib.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!("abc", timer_for_harvest::parse_account_details("GET /?access_token=abc&scope=harvest%3A123").0);
assert_eq!("abc", timer_for_harvest::parse_account_details("GET /?scope=harvest%3A123&access_token=abc").0);
}
#[test]
fn should_parse_expires_in() {
assert_eq!... | code_fim | medium | {
"lang": "rust",
"repo": "sftim/timer-for-harvest",
"path": "/tests/lib.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in 1..num {
use chacha::SeekableKeyStream;
let mut stream = key_type.chacha(shared_secrets[i - 1]);
stream
.seek_to(((OnionPacket::NUM_MAX_HOPS - i + 1) * HopBytes::SIZE) as _)
.unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "alishahusain/lpd",
"path": "/onion/src/route.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alishahusain/lpd path: /onion/src/route.rs
use dependencies::secp256k1;
use dependencies::chacha;
use dependencies::hex;
use dependencies::bitcoin_hashes;
use super::hop::{Hop, HopBytes};
use super::crypto::{HmacData, KeyType};
use super::packet::{OnionPacket, ValidOnionPacket};
use secp256k1:... | code_fim | hard | {
"lang": "rust",
"repo": "alishahusain/lpd",
"path": "/onion/src/route.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> // secp256k1 base point G
let base_point = {
// the string represents valid secp256k1 element, so both unwrap calls are safe
let s = "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798";
PublicKey::from_slice(hex::deco... | code_fim | hard | {
"lang": "rust",
"repo": "alishahusain/lpd",
"path": "/onion/src/route.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: polyhorn/polyhorn path: /crates/polyhorn-ui/src/styles/position.rs
use crate::geometry::{ByEdge, Dimension};
/// Controls the absolute positioning of a view.
#[derive(Copy, Clone, Debug, Default, PartialEq)]
pub struct Absolute {
/// Provides the distance of this view to each of the edges o... | code_fim | hard | {
"lang": "rust",
"repo": "polyhorn/polyhorn",
"path": "/crates/polyhorn-ui/src/styles/position.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Determines whether a view affects the layout of its ancestor and siblings.
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum Position {
/// If layed out absolutely, this view does not affect the layout of its
/// ancestor or siblings.
Absolute(Absolute),
/// If layed out relatively, t... | code_fim | hard | {
"lang": "rust",
"repo": "polyhorn/polyhorn",
"path": "/crates/polyhorn-ui/src/styles/position.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Relative {
flex_basis: Dimension::Undefined,
flex_grow: 0.0,
flex_shrink: 1.0,
}
}
}
/// Determines whether a view affects the layout of its ancestor and siblings.
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum Position {
/// If layed out abs... | code_fim | hard | {
"lang": "rust",
"repo": "polyhorn/polyhorn",
"path": "/crates/polyhorn-ui/src/styles/position.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sjmackenzie/chain-libs path: /chain-impl-mockchain/src/testing/address.rs
use crate::{
account::SpendingCounter,
key::{EitherEd25519SecretKey, SpendingPublicKey},
transaction::{Input, Output},
utxo::Entry,
value::Value,
};
use chain_addr::{Address, Discrimination, Kind, KindT... | code_fim | hard | {
"lang": "rust",
"repo": "sjmackenzie/chain-libs",
"path": "/chain-impl-mockchain/src/testing/address.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl AddressDataValue {
pub fn new(address_data: AddressData, value: Value) -> Self {
AddressDataValue {
address_data: address_data,
value: value,
}
}
pub fn make_input(&self, utxo: Option<Entry<Address>>) -> Input {
self.address_data.make_input... | code_fim | hard | {
"lang": "rust",
"repo": "sjmackenzie/chain-libs",
"path": "/chain-impl-mockchain/src/testing/address.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
impl nsIDOMElement {
/* readonly attribute DOMString tagName; */
#[inline]
pub unsafe fn get_tagName(&self, ) -> Result<nsString, nsresult> {
let mut _retval = nsString::new();
match ((*self.vtable).get_tagName)(self as *const _, &mut *_retval) {
NS_OK => {},
... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/rt/nsIDOMElement.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mystor/dist-xprs-example path: /rt/nsIDOMElement.rs
//
// DO NOT EDIT. THIS FILE IS GENERATED FROM ../../../dist/idl/nsIDOMElement.idl
//
#[repr(C)]
pub struct nsIDOMElement {
vtable: *const nsIDOMElementVTable,
/// This field is a phantomdata to ensure that the VTable type and any
... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/rt/nsIDOMElement.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /* nsIDOMAttr getAttributeNode (in DOMString name); */
#[inline]
pub unsafe fn getAttributeNode(&self, name: &[u16]) -> Result<Option<RefPtr<nsIDOMAttr>>, nsresult> {
let name = nsString::from(name);
let mut _retval = GetterAddrefs::new();
match ((*self.vtable).getAttri... | code_fim | hard | {
"lang": "rust",
"repo": "mystor/dist-xprs-example",
"path": "/rt/nsIDOMElement.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mellemahp/ray-tracing-in-one-weekend-in-rust path: /src/utils/hitable.rs
use std::vec::Vec;
use utils::{vec3, ray, material};
#[allow(dead_code)]
#[derive(Clone)]
pub struct HitRecord {
pub t: f32,
pub p: vec3::Vec3,
pub normal: vec3::Vec3,
pub mat: Box<material::Material>,
}
#... | code_fim | medium | {
"lang": "rust",
"repo": "mellemahp/ray-tracing-in-one-weekend-in-rust",
"path": "/src/utils/hitable.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Hitable for HitableList {
fn hit(&self, r: &ray::Ray, t_min: f32, t_max: f32, rec: &mut HitRecord) -> bool {
let mut temp_rec = HitRecord::new(rec.mat.clone());
let mut hit_anything = false;
let mut closest_so_far = t_max;
for h in self.list.iter() {
if... | code_fim | hard | {
"lang": "rust",
"repo": "mellemahp/ray-tracing-in-one-weekend-in-rust",
"path": "/src/utils/hitable.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ajm188/advent_of_code path: /2015/day02/main.rs
#![feature(iter_arith)]
use std::env::args;
use std::vec::Vec;
fn str_to_int(s: String) -> i32 {
i32::from_str_radix(&s, 10).ok().unwrap()
}
struct Present {
length: i32,
width: i32,
height: i32,
}
impl Present {
fn from_stri... | code_fim | hard | {
"lang": "rust",
"repo": "ajm188/advent_of_code",
"path": "/2015/day02/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.perimeters().iter().min().unwrap() + self.volume()
}
fn surface_area(&self) -> i32 {
self.side_surface_areas().iter().map(|s| s * 2).sum()
}
fn perimeters(&self) -> Vec<i32> {
vec![2 * (self.length + self.width),
2 * (self.length + self.height),
... | code_fim | medium | {
"lang": "rust",
"repo": "ajm188/advent_of_code",
"path": "/2015/day02/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> character_info.insert(character_id, (time_in_fleet, implants, skills));
}
let mut pilot_data = HashMap::new();
for (character_id, (time_in_fleet, implants, skills)) in character_info.iter() {
pilot_data.insert(
character_id,
tdf::fitcheck::PilotData {
... | code_fim | hard | {
"lang": "rust",
"repo": "Aquanable/waitlist",
"path": "/backend/src/routes/waitlist/xup.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Delete existing X'up for the hull
if let Some(existing_x) = sqlx::query!("
SELECT waitlist_entry_fit.id FROM waitlist_entry_fit JOIN fitting ON fit_id=fitting.id WHERE entry_id = ? AND hull = ?
", entry_id, fit.hull).fetch_optional(&mut tx).await? {
sqlx:... | code_fim | hard | {
"lang": "rust",
"repo": "Aquanable/waitlist",
"path": "/backend/src/routes/waitlist/xup.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Aquanable/waitlist path: /backend/src/routes/waitlist/xup.rs
use std::collections::{HashMap, HashSet};
use rocket::serde::json::Json;
use serde::Deserialize;
use crate::{
app::Application,
core::{
auth::{authorize_character, AuthenticatedAccount},
esi::ESIScope,
},
... | code_fim | hard | {
"lang": "rust",
"repo": "Aquanable/waitlist",
"path": "/backend/src/routes/waitlist/xup.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: erictobin18/rust_game path: /src/ecs/gravity_comp.rs
use amethyst::ecs::{Component, DenseVecStorage, WriteStorage, Entity};
use amethyst::Error;
use amethyst::derive::PrefabData;
use amethyst::assets::PrefabData;
use serde::{Serialize, Deserialize};
<|fim_suffix|>}
// impl Component for Gravi... | code_fim | medium | {
"lang": "rust",
"repo": "erictobin18/rust_game",
"path": "/src/ecs/gravity_comp.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// impl Component for GravityComponent {
// type Storage = DenseVecStorage<Self>;
// }<|fim_prefix|>// repo: erictobin18/rust_game path: /src/ecs/gravity_comp.rs
use amethyst::ecs::{Component, DenseVecStorage, WriteStorage, Entity};
use amethyst::Error;
use amethyst::derive::PrefabData;
use amethyst... | code_fim | medium | {
"lang": "rust",
"repo": "erictobin18/rust_game",
"path": "/src/ecs/gravity_comp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>}
// impl Component for GravityComponent {
// type Storage = DenseVecStorage<Self>;
// }<|fim_prefix|>// repo: erictobin18/rust_game path: /src/ecs/gravity_comp.rs
use amethyst::ecs::{Component, DenseVecStorage, WriteStorage, Entity};
use amethyst::Error;
use amethyst::derive::PrefabData;
use ameth... | code_fim | medium | {
"lang": "rust",
"repo": "erictobin18/rust_game",
"path": "/src/ecs/gravity_comp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn alu_rlc(&mut self, value: u8, set_zero: bool) -> u8 {
let co = value & 0x80;
let new_value = value.rotate_left(1);
self.registers.set_flag(set_zero && new_value == 0, false, co != 0, false);
new_value
}
fn alu_rrc(&mut self, value: u8, set_zero: bool) -> u8 ... | code_fim | hard | {
"lang": "rust",
"repo": "gavinlin/rustgb",
"path": "/src/cpu/core.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn rrc(&mut self, from: ByteTarget) {
let value = self.registers.get_byte(from);
let new_value = self.alu_rrc(value, true);
self.registers.set_byte(from, new_value);
}
fn rr(&mut self, from: ByteTarget) {
let value = self.registers.get_byte(from);
let n... | code_fim | hard | {
"lang": "rust",
"repo": "gavinlin/rustgb",
"path": "/src/cpu/core.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gavinlin/rustgb path: /src/cpu/core.rs
use super::registers::*;
pub enum Instruction {
LD(ByteTarget, ByteTarget),
ADD(ByteTarget),
ADC(ByteTarget),
SUB(ByteTarget),
SBC(ByteTarget),
INC(ByteTarget),
JP(JumpTest),
}
pub struct CPU {
pub registers: Registers,
... | code_fim | hard | {
"lang": "rust",
"repo": "gavinlin/rustgb",
"path": "/src/cpu/core.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc177/src/bin/e.rs
use proconio::input;
fn gcd(n: usize, m: usize) -> usize {
if n < m {
gcd(m, n)
} else if m == 0 {
n
} else {
gcd(m, n % m)
}
}
fn main() {
input! {
n: usize,
a: [... | code_fim | hard | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/abc177/src/bin/e.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ans = if pairwise {
"pairwise coprime"
} else if !pairwise && setwise == 1 {
"setwise coprime"
} else {
"not coprime"
};
println!("{}", ans);
}<|fim_prefix|>// repo: bouzuya/rust-atcoder path: /cargo-atcoder/contests/abc177/src/bin/e.rs
use proconio::input;... | code_fim | hard | {
"lang": "rust",
"repo": "bouzuya/rust-atcoder",
"path": "/cargo-atcoder/contests/abc177/src/bin/e.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Cpu {
ram,
v,
i,
pc,
dt,
st,
rng: rand::thread_rng(),
stack: Vec::new(),
}
}
pub fn decrement_timers(&mut self) {
if self.dt > 0 {
self.dt-= 1;
}
if ... | code_fim | hard | {
"lang": "rust",
"repo": "nacho-vlad/chio",
"path": "/src/cpu.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
let opcode = ( (byte1 & 0xF0) >> 4, byte1 & 0x0F, (byte2 & 0xF0) >> 4, byte2 & 0x0F );
// println!("{:X?}", opcode);
let x = byte1 as usize & 0x0F;
let y = (byte2 as usize & 0xF0) >> 4;
let kk = byte2;
let n = byte2 & 0x0F;
let nnn = ((byte1 as u16 ... | code_fim | hard | {
"lang": "rust",
"repo": "nacho-vlad/chio",
"path": "/src/cpu.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nacho-vlad/chio path: /src/cpu.rs
use super::peripherals::{Framebuffer, Keypad};
use rand::prelude::*;
#[derive(Clone)]
pub struct Cpu {
ram: [u8; 4069],
v: [u8; 16],
i: u16,
pc: u16,
dt: u8,
st: u8,
rng : rand::rngs::ThreadRng,
stack: Vec<u16>,
}
impl... | code_fim | hard | {
"lang": "rust",
"repo": "nacho-vlad/chio",
"path": "/src/cpu.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alsacoin/alsacoin path: /models/src/coinbase.rs
//! # Coinbase
//!
//! The `coinbase` module contains the `Coinbase` type and functions.
use crate::address::Address;
use crate::error::Error;
use crate::result::Result;
use crypto::hash::balloon::BalloonParams;
use crypto::hash::Digest;
use minin... | code_fim | hard | {
"lang": "rust",
"repo": "alsacoin/alsacoin",
"path": "/models/src/coinbase.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for h in hs.iter() {
for d in ds.iter() {
let res = Coinbase::new(&address, *h, *d);
assert!(res.is_ok());
}
}
}
#[test]
fn test_coinbase_new_eve() {
let address = Address::random().unwrap();
let res = Coinbase::new_eve(&address);
assert!(res.i... | code_fim | hard | {
"lang": "rust",
"repo": "alsacoin/alsacoin",
"path": "/models/src/coinbase.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut coinbase = Coinbase::default();
let res = coinbase.validate();
assert!(res.is_ok());
coinbase.params = valid_params;
coinbase.distance = valid_distance;
coinbase.difficulty = valid_difficulty;
let res = coinbase.validate();
assert!(r... | code_fim | hard | {
"lang": "rust",
"repo": "alsacoin/alsacoin",
"path": "/models/src/coinbase.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let needle = idx * MERKLE_ARITY;
for i in 0..MERKLE_ARITY {
if let Some(n) = self.node(height + 1, needle + i)? {
h.insert_unchecked(i, n);
}
}
let node = h.hash();
if should_cache {
... | code_fim | hard | {
"lang": "rust",
"repo": "dusk-network/dusk-poseidon-merkle",
"path": "/src/big_merkle/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dusk-network/dusk-poseidon-merkle path: /src/big_merkle/mod.rs
use crate::{Error, Poseidon, PoseidonLeaf, Scalar, MERKLE_ARITY};
use std::cmp;
use std::convert::TryInto;
use std::ops;
use std::path::Path;
use std::sync::{mpsc, Arc, Mutex};
use std::thread;
use rocksdb::DB;
#[cfg(test)]
use tem... | code_fim | hard | {
"lang": "rust",
"repo": "dusk-network/dusk-poseidon-merkle",
"path": "/src/big_merkle/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: D1plo1d/async-graphql path: /src/extensions/logger.rs
use std::fmt::{self, Display, Formatter};
use log::{error, info, trace};
use crate::extensions::{Extension, ExtensionContext, ExtensionFactory, ResolveInfo};
use crate::parser::types::{ExecutableDocument, OperationType, Selection};
use crat... | code_fim | hard | {
"lang": "rust",
"repo": "D1plo1d/async-graphql",
"path": "/src/extensions/logger.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
_ctx: &ExtensionContext<'_>,
query_source: &str,
variables: &Variables,
) {
self.query = query_source.replace(char::is_whitespace, "");
self.variables = variables.clone();
}
fn parse_end(&mut self, _ctx: &ExtensionContext<'_>, documen... | code_fim | hard | {
"lang": "rust",
"repo": "D1plo1d/async-graphql",
"path": "/src/extensions/logger.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match segment {
PathSegment::Field(field) => write!(f, "{}", field),
PathSegment::Index(i) => write!(f, "{}", i),
}?;
}
write!(f, ", ")?;
}
... | code_fim | hard | {
"lang": "rust",
"repo": "D1plo1d/async-graphql",
"path": "/src/extensions/logger.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Jimskapt/rust-book-fr path: /FRENCH/listings/ch18-patterns-and-matching/listing-18-01/src/main.rs
fn main() {
let couleur_favorite: Option<&str> = None;
let on_est_mardi = false;
let age: Result<u8, _> = "34".parse();
if let Some(couleur) = coule<|fim_suffix|>{
print... | code_fim | hard | {
"lang": "rust",
"repo": "Jimskapt/rust-book-fr",
"path": "/FRENCH/listings/ch18-patterns-and-matching/listing-18-01/src/main.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>{
println!("Utilisation de l'orange comme couleur de fond");
}
} else {
println!("Utilisation du bleu comme couleur de fond");
}
}<|fim_prefix|>// repo: Jimskapt/rust-book-fr path: /FRENCH/listings/ch18-patterns-and-matching/listing-18-01/src/main.rs
fn main() {
le... | code_fim | hard | {
"lang": "rust",
"repo": "Jimskapt/rust-book-fr",
"path": "/FRENCH/listings/ch18-patterns-and-matching/listing-18-01/src/main.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mkdika/learn-rust path: /automatedtests/src/lib.rs
#[derive(Debug)]
pub struct Rectangle {
length: u32,
width: u32,
}
impl Rectangle {
pub fn can_hold(&self, other: &Rectangle) -> bool {
self.length > other.length && self.width > other.width
}
}
pub fn add_two(a: i32) ->... | code_fim | hard | {
"lang": "rust",
"repo": "mkdika/learn-rust",
"path": "/automatedtests/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(larger.can_hold(&smaller));
}
// assert_eq to expect equality
#[test]
fn it_adds_two() {
assert_eq!(4, add_two(2));
}
// custom message if failed
#[test]
fn greeting_contains_name() {
let result = greeting("Carol");
assert!(
... | code_fim | hard | {
"lang": "rust",
"repo": "mkdika/learn-rust",
"path": "/automatedtests/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /third_party/rust_crates/vendor/trust-dns-proto-0.22.0/src/rr/dnssec/verifier.rs
//! Verifier is a structure for performing many of the signing processes of the DNSSec specification
use crate::error::*;
use crate::rr::dnssec::rdata::{DNSKEY, KEY, SIG};
use crate::rr::dnss... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/trust-dns-proto-0.22.0/src/rr/dnssec/verifier.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> PublicKeyEnum::from_public_bytes(self.public_key(), self.algorithm())
}
}
impl Verifier for KEY {
fn algorithm(&self) -> Algorithm {
self.algorithm()
}
fn key(&self) -> ProtoResult<PublicKeyEnum<'_>> {
PublicKeyEnum::from_public_bytes(self.public_key(), self.algor... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/trust-dns-proto-0.22.0/src/rr/dnssec/verifier.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self,
message: &M,
signature: &[u8],
sig0: &SIG,
) -> ProtoResult<()> {
tbs::message_tbs(message, sig0).and_then(|tbs| self.verify(tbs.as_ref(), signature))
}
/// Verifies an RRSig with the associated key, e.g. DNSKEY
///
/// # Arguments
//... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/third_party/rust_crates/vendor/trust-dns-proto-0.22.0/src/rr/dnssec/verifier.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TheooAndre/rust-beginner-projects path: /examples/coin_estimator_by_weight.rs
extern crate rust_beginner_projects;
use rust_beginner_projects::coin_estimator_by_weight;
use rust_beginner_projects::coin_estimator_by_weight::CoinType;
<|fim_suffix|> const WEIGHT: f64 = 223.0;
const TYPE: C... | code_fim | easy | {
"lang": "rust",
"repo": "TheooAndre/rust-beginner-projects",
"path": "/examples/coin_estimator_by_weight.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> const WEIGHT: f64 = 223.0;
const TYPE: CoinType = CoinType::Quarter;
let (amount, rolls) = coin_estimator_by_weight::estimate(TYPE, WEIGHT);
println!("{} grams = {} with {} coin rolls", WEIGHT, amount, rolls);
}<|fim_prefix|>// repo: TheooAndre/rust-beginner-projects path: /examples/coin_... | code_fim | easy | {
"lang": "rust",
"repo": "TheooAndre/rust-beginner-projects",
"path": "/examples/coin_estimator_by_weight.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: caibirdme/leetcode_rust path: /src/prob_5266.rs
use std::collections::HashSet;
impl Solution {
pub fn min_push_box(grid: Vec<Vec<char>>) -> i32 {
let mut visited: HashSet<(usize,usize,usize,usize)> = HashSet::new();
let n = grid.len();
let m = grid[0].len();
... | code_fim | hard | {
"lang": "rust",
"repo": "caibirdme/leetcode_rust",
"path": "/src/prob_5266.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl State {
fn new(ux: usize, uy: usize, bx: usize, by: usize, step: i32) -> Self {
Self{
worker: (ux,uy),
cargo: (bx, by),
step,
}
}
fn spread(&self) -> (usize,usize,usize,usize) {
(self.worker.0, self.worker.1,self.cargo.0,self.car... | code_fim | hard | {
"lang": "rust",
"repo": "caibirdme/leetcode_rust",
"path": "/src/prob_5266.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: devfans/Maester path: /src/app.rs
use crate::span::cursor::CursorSpan;
use crate::span::godswood;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub struct Application {
app: wand::core::Application,
}
#[wasm_bindgen]
impl Application {
pub fn new() -> Self {
let mut app = wand... | code_fim | hard | {
"lang": "rust",
"repo": "devfans/Maester",
"path": "/src/app.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn draw(&self) {
self.app.draw();
}
pub fn tick(&mut self) {
self.app.tick();
}
pub fn on_size_change(&mut self) {
self.app.on_resize();
}
pub fn on_keyup(&mut self, key: &str) {
self.app.on_keyup(key);
}
pub fn on_keydown(&mut ... | code_fim | hard | {
"lang": "rust",
"repo": "devfans/Maester",
"path": "/src/app.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mabruckner/ourCAD path: /src/parser/util.rs
/// Returns the line number and column number tuple given a byte offset into a string
pub fn get_col_line_number(s: &str, byte_offset: usize) -> (i32, i32) {
let mut line_count = 1;
let mut col_count = 1;
let mut counter = 0;
if s == "" {
r... | code_fim | hard | {
"lang": "rust",
"repo": "mabruckner/ourCAD",
"path": "/src/parser/util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.