text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: fkaa/atsssvt path: /src/main.rs
#![allow(dead_code)]
#![allow(unused_variables)]
extern crate winapi;
extern crate term;
#[macro_use]
extern crate derivative;
extern crate svg;
#[macro_use]
extern crate bitflags;
use winapi::um::d3d12::*;
use winapi::um::d3d12sdklayers::*;
use winapi::um::d3d... | code_fim | hard | {
"lang": "rust",
"repo": "fkaa/atsssvt",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut fg = FrameGraph::new(device.device);
let desc = GraphicsPipelineDescription {
vertex_shader: ShaderBlob::from_file("Basic.v"),
pixel_shader: Some(ShaderBlob::from_file("Basic.p")),
domain_shader: None,
hull_shader: None,
geometry_shader: None,
... | code_fim | hard | {
"lang": "rust",
"repo": "fkaa/atsssvt",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
(*list).ClearRenderTargetView(*color_rtv, &[0.8f32, 0.4f32, 0.3f32, 1f32], 0, ::std::ptr::null_mut());
}
})
);
let _ = fg.add_pass(
"Dummy",
|builder| {
... | code_fim | hard | {
"lang": "rust",
"repo": "fkaa/atsssvt",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let id = match id.trim().parse::<u64>() {
Ok(id) => id,
Err(_) => return Ok((None, None)),
};
let res = get_data!(ctx, ::DbPool)
.prep_exec("UPDATE images SET name = ? WHERE id = ?", (name.trim(), id));
match ... | code_fim | hard | {
"lang": "rust",
"repo": "lolzballs/lolzbot",
"path": "/src/commands/rename.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let res = get_data!(ctx, ::DbPool)
.prep_exec("UPDATE images SET name = ? WHERE id = ?", (name.trim(), id));
match res {
Ok(res) => {
if res.affected_rows() == 0 {
Ok((None, None))
} els... | code_fim | hard | {
"lang": "rust",
"repo": "lolzballs/lolzbot",
"path": "/src/commands/rename.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lolzballs/lolzbot path: /src/commands/rename.rs
use mysql;
use serenity::client::Context;
use serenity::model::channel::Message;
pub const PREFIX: &'static str = "rename";
pub fn handle(ctx: &Context, msg: &Message, cmd: &str) -> super::CommandResult {
match ::CONFIG.admins.iter().find(|&&... | code_fim | hard | {
"lang": "rust",
"repo": "lolzballs/lolzbot",
"path": "/src/commands/rename.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LU15W1R7H/corgis path: /src/intelligence/mod.rs
pub mod brain;
pub mod decision;
pub mod perception;
// for testing the IO
mod test;
use super::test;
use bevy::prelude::*;
use bevy_rapier2d::{physics::RigidBodyHandleComponent, rapier::dynamics::RigidBodySet};
use crate::corgi::{Corgi, Energy}... | code_fim | hard | {
"lang": "rust",
"repo": "LU15W1R7H/corgis",
"path": "/src/intelligence/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl BrainStore for Decision {
fn len(&self) -> usize {
self.vec.len()
}
}
// always has to be emptied in the same order
impl BrainOutputStore for Decision {
fn take(&mut self) -> f32 {
self.vec.pop().expect("No more outputs left")
}
fn take_multiple(&mut self, n: usi... | code_fim | hard | {
"lang": "rust",
"repo": "LU15W1R7H/corgis",
"path": "/src/intelligence/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> W(writer)
}
}
#[doc = "Field `MPL` reader - Maximum packet length"]
pub type MPL_R = crate::FieldReader<u8, u8>;
#[doc = "Field `MPL` writer - Maximum packet length"]
pub type MPL_W<'a, const O: u8> = crate::FieldWriter<'a, u32, DIEP0CTL_SPEC, u8, u8, 2, O>;
#[doc = "Field `EPACT` reader - end... | code_fim | hard | {
"lang": "rust",
"repo": "riscv-rust/gd32vf103-pac",
"path": "/src/usbfs_device/diep0ctl.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: riscv-rust/gd32vf103-pac path: /src/usbfs_device/diep0ctl.rs
#[doc = "Register `DIEP0CTL` reader"]
pub struct R(crate::R<DIEP0CTL_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<DIEP0CTL_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "riscv-rust/gd32vf103-pac",
"path": "/src/usbfs_device/diep0ctl.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jjbayer/restorable path: /src/notebook.rs
use serde::de::DeserializeOwned;
use serde::Deserialize;
use std::error::Error;
use std::path::Path;
use crate::json;
use crate::page::Page;
#[derive(Debug, Deserialize)]
struct Content {
pages: Vec<String>,
}
#[derive(Debug)]
pub struct Notebook {... | code_fim | medium | {
"lang": "rust",
"repo": "jjbayer/restorable",
"path": "/src/notebook.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(Notebook { content, pages })
}
}
pub fn parse<T: DeserializeOwned>(path: &str, postfix: &str) -> Result<T, Box<dyn Error>> {
let full_path = format!("{}{}", path, postfix);
json::parse(Path::new(&full_path))
}<|fim_prefix|>// repo: jjbayer/restorable path: /src/notebook.rs
use ser... | code_fim | hard | {
"lang": "rust",
"repo": "jjbayer/restorable",
"path": "/src/notebook.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut pages: Vec<Page> = vec![];
for page_id in &content.pages {
match Page::load(path, page_id) {
Err(e) => {
return Err(e);
}
Ok(page) => {
pages.push(page);
}
... | code_fim | medium | {
"lang": "rust",
"repo": "jjbayer/restorable",
"path": "/src/notebook.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Zach7893/Project-Euler path: /problem_2/src/main.rs
fn main() {
//By considering the terms in the Fibonacci sequence whose
//values do not exceed four million, find the sum of the even-valued terms
// variable for running total
let mut total = 0;
let mut numbers = vec![... | code_fim | medium | {
"lang": "rust",
"repo": "Zach7893/Project-Euler",
"path": "/problem_2/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for n in &numbers {
if n % 2 == 0 {
total += n;
}
}
println!("{}",total);
}<|fim_prefix|>// repo: Zach7893/Project-Euler path: /problem_2/src/main.rs
fn main() {
//By considering the terms in the Fibonacci sequence whose
//values do not exceed four millio... | code_fim | hard | {
"lang": "rust",
"repo": "Zach7893/Project-Euler",
"path": "/problem_2/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> while let Some(node) = curr_head {
result *= 2;
result += node.val;
curr_head = &node.next;
}
return result;
}
}
fn main() {
println!("Hello, world!");
}<|fim_prefix|>// repo: abdullahwaqar/leetcode path: /1290.Convert_Binary_Number_in... | code_fim | medium | {
"lang": "rust",
"repo": "abdullahwaqar/leetcode",
"path": "/1290.Convert_Binary_Number_in_a_Linked_List_to_Integer/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: abdullahwaqar/leetcode path: /1290.Convert_Binary_Number_in_a_Linked_List_to_Integer/src/main.rs
// Definition for singly-linked list.
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct ListNode {
pub val: i32,
pub next: Option<Box<ListNode>>,
}
<|fim_suffix|> while let Some(node)... | code_fim | hard | {
"lang": "rust",
"repo": "abdullahwaqar/leetcode",
"path": "/1290.Convert_Binary_Number_in_a_Linked_List_to_Integer/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Solution {
pub fn get_decimal_value(head: Option<Box<ListNode>>) -> i32 {
let mut curr_head = &head;
let mut result = 0;
while let Some(node) = curr_head {
result *= 2;
result += node.val;
curr_head = &node.next;
}
retu... | code_fim | medium | {
"lang": "rust",
"repo": "abdullahwaqar/leetcode",
"path": "/1290.Convert_Binary_Number_in_a_Linked_List_to_Integer/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_get_health_check() {
match health_check() {
Ok(_) => (),
Err(e) => println!("Error in async_health_check: {}", e),
};
let health: String = match get_health_check() {
Ok(v) => v,
Err(e) => panic!("Error in get n... | code_fim | hard | {
"lang": "rust",
"repo": "Mutestock/dbd_exam",
"path": "/backend/src/data_access/redis_connection.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub async fn get_async_health_check() -> redis::RedisResult<String> {
let health_check = make_async_redis_connection().await?.get("health").await?;
Ok(health_check)
}
pub async fn async_health_check() -> redis::RedisResult<()> {
make_async_redis_connection()
.await?
.set("heal... | code_fim | hard | {
"lang": "rust",
"repo": "Mutestock/dbd_exam",
"path": "/backend/src/data_access/redis_connection.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Mutestock/dbd_exam path: /backend/src/data_access/redis_connection.rs
#![allow(dead_code)]
use crate::utils::environment::load_variables;
use redis::{self, AsyncCommands, Commands};
use std::env;
lazy_static! {
static ref REDIS_CONNECTION_STRING: String = {
load_variables();
... | code_fim | hard | {
"lang": "rust",
"repo": "Mutestock/dbd_exam",
"path": "/backend/src/data_access/redis_connection.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tc2n/basic-AstroBlasto path: /src/main.rs
use rand;
use tetra::{self, State, Context, ContextBuilder};
use tetra::audio;
use tetra::graphics::{self, Color, DrawParams, Font, Texture, Rectangle};
use tetra::math::Vec2;
use tetra::input::{self,Key};
use std::result;
const SHOT_SPEED: f32 = 200.0... | code_fim | hard | {
"lang": "rust",
"repo": "tc2n/basic-AstroBlasto",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn check_for_level_respawn(&mut self, ctx: &mut Context) {
if self.rocks.is_empty() {
self.level += 1;
let r = create_rocks(ctx, self.level + 5, self.player.pos, 100.0, 250.0);
self.rocks.extend(r);
}
}
}
/// ************************************... | code_fim | hard | {
"lang": "rust",
"repo": "tc2n/basic-AstroBlasto",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: raptorswing/tftprust path: /src/packets.rs
use crate::errors::TFTPError;
use std::convert::TryFrom;
use std::convert::TryInto;
use std::string::String;
use std::vec::Vec;
const OPCODE_READ_REQUEST: u16 = 1;
const OPCODE_WRITE_REQUEST: u16 = 2;
const OPCODE_DATA: u16 = 3;
const OPCODE_ACK: u16 =... | code_fim | hard | {
"lang": "rust",
"repo": "raptorswing/tftprust",
"path": "/src/packets.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Write the mode.
// We don't currently do netascii conversion here because the only modes we support are known
// in advance to not need any conversion.
let mode_str: &str = mode.into();
for x in mode_str.as_bytes() {
... | code_fim | hard | {
"lang": "rust",
"repo": "raptorswing/tftprust",
"path": "/src/packets.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> use pulldown_cmark::*;
let mut s = String::new();
let opts = OPTION_ENABLE_TABLES;
let p = Parser::new_ext(&original, opts);
html::push_html(&mut s, p);
assert_eq!(expected, s);
}
#[test]
fn table_test_9() {
let original = r##"|Col 1|... | code_fim | hard | {
"lang": "rust",
"repo": "mearie/pulldown-cmark",
"path": "/tests/table.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mearie/pulldown-cmark path: /tests/table.rs
// This file is auto-generated by the build script
// Please, do not modify it manually
extern crate pulldown_cmark;
#[test]
fn table_test_1() {
let original = r##"Test header
-----------
"##;
let expected = r##"<h2>Test head... | code_fim | hard | {
"lang": "rust",
"repo": "mearie/pulldown-cmark",
"path": "/tests/table.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexheretic/single-value-channel path: /src/lib.rs
//! Single value update and receive channel.
//!
//! This module provides a latest-message style channel, where update sources can update the
//! latest value that the receiver owns in a practically non-blocking way.
//!
//! Unlike the `mpsc::ch... | code_fim | hard | {
"lang": "rust",
"repo": "alexheretic/single-value-channel",
"path": "/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn non_blocking_write_during_read() {
let (mut name_get, name) = channel_starting_with("Nothing".to_owned());
let (barrier, barrier2) = barrier_pair();
thread::spawn(move || {
barrier2.wait(); // <- has read lock
name.update("Something".to_ow... | code_fim | hard | {
"lang": "rust",
"repo": "alexheretic/single-value-channel",
"path": "/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ForsakenHarmony/esp32c3-pac path: /src/extmem/extmem_cache_ilg_int_ena.rs
#[doc = "Reader of register EXTMEM_CACHE_ILG_INT_ENA"]
pub type R = crate::R<u32, super::EXTMEM_CACHE_ILG_INT_ENA>;
#[doc = "Writer for register EXTMEM_CACHE_ILG_INT_ENA"]
pub type W = crate::W<u32, super::EXTMEM_CACHE_ILG... | code_fim | hard | {
"lang": "rust",
"repo": "ForsakenHarmony/esp32c3-pac",
"path": "/src/extmem/extmem_cache_ilg_int_ena.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mu_entry_fault_int_ena(&self) -> EXTMEM_MMU_ENTRY_FAULT_INT_ENA_R {
EXTMEM_MMU_ENTRY_FAULT_INT_ENA_R::new(((self.bits >> 5) & 0x01) != 0)
}
#[doc = "Bit 1"]
#[inline(always)]
pub fn extmem_icache_preload_op_fault_int_ena(
&self,
) -> EXTMEM_ICACHE_PRELOAD_OP_FAULT_INT_E... | code_fim | hard | {
"lang": "rust",
"repo": "ForsakenHarmony/esp32c3-pac",
"path": "/src/extmem/extmem_cache_ilg_int_ena.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: woboq/qmetaobject-rs path: /qmetaobject/src/future.rs
use std::future::Future;
use std::mem::replace;
use std::os::raw::c_void;
use std::pin::Pin;
use std::task::{Context, Poll, RawWaker, RawWakerVTable, Waker};
use cpp::cpp;
use crate::connections::SignalArgArrayToTuple;
static QT_WAKER_VTAB... | code_fim | hard | {
"lang": "rust",
"repo": "woboq/qmetaobject-rs",
"path": "/qmetaobject/src/future.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> struct ConnectionFuture<Args: SignalArgArrayToTuple>(ConnectionFutureState<Args>);
impl<Args: SignalArgArrayToTuple> Drop for ConnectionFuture<Args> {
fn drop(&mut self) {
if let ConnectionFutureState::Started { ref mut handle, .. } = &mut self.0 {
handle.disco... | code_fim | hard | {
"lang": "rust",
"repo": "woboq/qmetaobject-rs",
"path": "/qmetaobject/src/future.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Create a future that waits on the emission of a signal.
///
/// The arguments of the signal need to implement `Clone`, and the Output of the future is a tuple
/// containing the arguments of the signal (or the empty tuple if there are none.)
///
/// The future will be ready as soon as the signal is em... | code_fim | hard | {
"lang": "rust",
"repo": "woboq/qmetaobject-rs",
"path": "/qmetaobject/src/future.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Alagris/rust_server_test path: /backend/src/main.rs
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
use dotenv::dotenv;
use mongodb::{Client, options::ClientOptions};
use std::sync::atomic::{AtomicUsize, Ordering};
use futures::stream::StreamExt;
use r2d2_mongodb:... | code_fim | hard | {
"lang": "rust",
"repo": "Alagris/rust_server_test",
"path": "/backend/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
struct HitCount {
count: AtomicUsize
}
#[derive(Serialize)]
struct Product {
title:String,
url:String,
img_url:String,
about:String,
price:String,
}
#[get("/?<q>&<max>")]
fn index(q: Option<String>,max:Option<NonZeroUsize>,connection: Conn) -> Json<Vec<P... | code_fim | hard | {
"lang": "rust",
"repo": "Alagris/rust_server_test",
"path": "/backend/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: akurtasinski/purpleproxy path: /src/lib.rs
#![feature(libc,path,core,fs,io,linkage,std_misc)]
#![allow(dead_code)]
extern crate capnp;
extern crate "capnp-rpc" as capnp_rpc;
extern crate libc;
pub const RTLD_NEXT: *mut u8 = 0xffffffffffffffff as *mut u8;
pub mod stubs;
mod types_capnp {
... | code_fim | hard | {
"lang": "rust",
"repo": "akurtasinski/purpleproxy",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
#[no_stack_check]
#[linkage = "external"]
pub unsafe extern "C" fn __libc_start_main(main: Option<extern "C" fn (int,
*const *const u8,
*const *const ... | code_fim | hard | {
"lang": "rust",
"repo": "akurtasinski/purpleproxy",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cw124/wonder path: /src/table.rs
//! Makes it easier to print text-based tables with lined-up columns.
pub struct Table {
rows: Vec<Vec<String>>,
num_columns: usize,
}
impl Table {
/// Creates a new [Table]. Each column will have the given header text.
pub fn new(header: Vec<St... | code_fim | hard | {
"lang": "rust",
"repo": "cw124/wonder",
"path": "/src/table.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Prints the table to stdout. Each line will be prefixed with the given string, and each column will be separated
/// by the given amount of whitespace.
pub fn print(&self, prefix: &str, column_spacing: u32) {
let widths: Vec<usize> = self.rows[0]
.iter()
.enu... | code_fim | hard | {
"lang": "rust",
"repo": "cw124/wonder",
"path": "/src/table.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for row in &self.rows {
print!("{}", prefix);
for (i, cell) in row.iter().enumerate() {
print!("{:width$}", cell, width = widths[i])
}
println!();
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
#[should... | code_fim | hard | {
"lang": "rust",
"repo": "cw124/wonder",
"path": "/src/table.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>[0])),
MLIRType(&unit.value_type(data.args()[1])),
MLIRType(&unit.value_type(data.args()[2])),
MLIRType(&unit.value_type(unit.inst_result(inst)))
)?;
}
Opcode::Mux => {
write!(self.writer.si... | code_fim | hard | {
"lang": "rust",
"repo": "skanjani/llhd",
"path": "/src/mlir/writer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Uniquify a value or block name.
fn uniquify_name(&mut self, name: Option<&str>) -> Rc<String> {
if let Some(requested_name) = name {
let requested_name = escape_name(requested_name);
let idx = self.name_indices.entry(requested_name.clone()).or_insert(0);
... | code_fim | hard | {
"lang": "rust",
"repo": "skanjani/llhd",
"path": "/src/mlir/writer.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: skanjani/llhd path: /src/mlir/writer.rs
ice = data[shft_user].opcode() {
write!(uw.writer.sink, " = llhd.dyn_extract_slice ")?;
} else {
write!(uw.writer.sink, " = llhd... | code_fim | hard | {
"lang": "rust",
"repo": "skanjani/llhd",
"path": "/src/mlir/writer.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self,
image: &mut DebugImage,
_meta: &mut Meta,
_state: &ProcessingState<'_>,
) -> ValueAction {
if let DebugImage::Apple(ref mut apple) = image {
let native = NativeDebugImage {
code_id: Annotated::empty(),
code_... | code_fim | hard | {
"lang": "rust",
"repo": "forkkit/semaphore",
"path": "/general/src/store/legacy.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: forkkit/semaphore path: /general/src/store/legacy.rs
use std::mem;
use debugid::DebugId;
use crate::processor::{ProcessingState, Processor};
use crate::protocol::{DebugImage, NativeDebugImage};
use crate::types::{Annotated, Meta, Object, ValueAction};
<|fim_suffix|> &mut self,
... | code_fim | hard | {
"lang": "rust",
"repo": "forkkit/semaphore",
"path": "/general/src/store/legacy.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if sequence_instructions.owner != *owner_account_info.key {
return Err(ProgramError::InvalidAccountData);
}
let dest_starting_lamports = owner_account_info.lamports();
**owner_account_info.lamports.borrow_mut() = dest_starting_lamports
.checked_add(... | code_fim | hard | {
"lang": "rust",
"repo": "DappioLab/solana-contract-wallet",
"path": "/src/processor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DappioLab/solana-contract-wallet path: /src/processor.rs
ught weight
fn check_signatures(accounts: &[AccountInfo], wallet_account: &Account) -> ProgramResult {
let mut total_key_weight = 0;
let mut counted = BTreeMap::new();
for account in accounts.iter() {
... | code_fim | hard | {
"lang": "rust",
"repo": "DappioLab/solana-contract-wallet",
"path": "/src/processor.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if !owner_account_info.is_signer {
msg!(&format!("{} should be a signer", owner_account_info.key));
return Err(ProgramError::MissingRequiredSignature);
}
let instruction_buffer =
InstructionBuffer::unpack(&instruction_buffer_account_info.data.bor... | code_fim | hard | {
"lang": "rust",
"repo": "DappioLab/solana-contract-wallet",
"path": "/src/processor.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 4JX/mCubed path: /back/src/mod_file/mod.rs
use core::fmt;
use std::{fmt::Debug, path::PathBuf};
use ferinth::structures::version_structs::{ModLoader as FeModLoader, VersionFile};
use mc_mod_meta::{fabric::FabricManifest, forge::ForgeModEntry, ModLoader as McModLoader};
use serde::{Deserialize,... | code_fim | hard | {
"lang": "rust",
"repo": "4JX/mCubed",
"path": "/back/src/mod_file/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mod_name = fabric_manifest
.name
.unwrap_or_else(|| fabric_manifest.id.clone());
let parsed_authors = fabric_manifest.authors.map_or_else(
|| None,
|authors| {
Some(
authors
.it... | code_fim | hard | {
"lang": "rust",
"repo": "4JX/mCubed",
"path": "/back/src/mod_file/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/non_conformant/parser/operations/logic_ne/dimensions/pairs.rs
//! Tests auto-converted from "sass-spec/spec/non_conformant/parser/operations/logic_ne/dimensions/pairs.hrx"
#[allow(unused)]
fn runner() -> crate::TestRunner {
super::runner().with_cwd("pairs")... | code_fim | hard | {
"lang": "rust",
"repo": "kaj/rsass",
"path": "/rsass/tests/spec/non_conformant/parser/operations/logic_ne/dimensions/pairs.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>: true 0px;\
\n test-36: true 0px;\
\n test-37: true px;\
\n test-38: true px;\
\n test-39: true px;\
\n test-40: true px;\
\n test-41: true px;\
\n test-42: true px;\
\n test-43: true px;\
\n test-44: true px;\
... | code_fim | hard | {
"lang": "rust",
"repo": "kaj/rsass",
"path": "/rsass/tests/spec/non_conformant/parser/operations/logic_ne/dimensions/pairs.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: squidboylan/registry-rs path: /src/storage/memory.rs
use std::collections::HashMap;
use std::sync::RwLock;
use actix_web::HttpResponse;
use bytes::Bytes;
use super::Backend;
use uuid::Uuid;
/// MemoryBackend provides an all in memory storage backend for the registry, this is useful only
/// f... | code_fim | hard | {
"lang": "rust",
"repo": "squidboylan/registry-rs",
"path": "/src/storage/memory.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn delete_upload(&self, repository: String, id: String) -> HttpResponse {
let repos_lock = self.repos.read().unwrap();
let repo = repos_lock.get(&repository).unwrap();
let mut uploads_lock = repo.uploads.write().unwrap();
let upload = uploads_lock.remove(&id);
... | code_fim | hard | {
"lang": "rust",
"repo": "squidboylan/registry-rs",
"path": "/src/storage/memory.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jnatten/mrt path: /src/util.rs
use colored::Colorize;
use std::path::{Path, PathBuf};
pub fn expand_path(input: &str) -> PathBuf {
let expanded = String::from(shellexpand::tilde(input));
PathBuf::from(expanded)
}
pub fn expand_pathbuf(input: PathBuf) -> PathBuf {
let path_as_str = ... | code_fim | hard | {
"lang": "rust",
"repo": "jnatten/mrt",
"path": "/src/util.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let path1 = PathBuf::from("/home");
let result1 = format_path_with_homedir(&path1, Some(PathBuf::from("/home/test")), '/');
let expected1 = (String::from("/"), String::from("home"));
assert_eq!(result1, expected1);
}
#[test]
fn test_formatting_for_relative() {... | code_fim | hard | {
"lang": "rust",
"repo": "jnatten/mrt",
"path": "/src/util.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mnts26/aws-sdk-rust path: /sdk/aws-config/src/environment/credentials.rs
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
use std::env::VarError;
use aws_types::credentials::future;
use aws_types::credentials::{CredentialsErro... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/aws-config/src/environment/credentials.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn secret_key_fallback() {
let provider = make_provider(&[
("AWS_ACCESS_KEY_ID", "access"),
("SECRET_ACCESS_KEY", "secret"),
("AWS_SESSION_TOKEN", "token"),
]);
let creds = provider
.provide_credentials()
... | code_fim | hard | {
"lang": "rust",
"repo": "mnts26/aws-sdk-rust",
"path": "/sdk/aws-config/src/environment/credentials.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: keiichiw/v4l2_rust path: /src/ioctl/reqbufs.rs
//! Safe wrapper for the `VIDIOC_REQBUFS` ioctl.
use crate::bindings;
use crate::memory::MemoryType;
use crate::QueueType;
use crate::Result;
use bitflags::bitflags;
use std::mem;
use std::os::unix::io::AsRawFd;
/// Implementors can receive the res... | code_fim | hard | {
"lang": "rust",
"repo": "keiichiw/v4l2_rust",
"path": "/src/ioctl/reqbufs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Full result of the `reqbufs` ioctl.
pub struct RequestBuffers {
pub count: u32,
pub capabilities: BufferCapabilities,
}
impl ReqBufs for RequestBuffers {
fn from(reqbufs: bindings::v4l2_requestbuffers) -> Self {
RequestBuffers {
count: reqbufs.count,
capabi... | code_fim | hard | {
"lang": "rust",
"repo": "keiichiw/v4l2_rust",
"path": "/src/ioctl/reqbufs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-17431-6.rs
use std::sync::Mutex;
<|fim_suffix|>impl Foo { fn bar(self) {} }
fn main() {}<|fim_middle|>enum Foo { X(Mutex<Option<Foo>>) }
//~^ ERROR recursive type `Foo` has infinite size
| code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/issues/issue-17431-6.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Foo { fn bar(self) {} }
fn main() {}<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/test/ui/issues/issue-17431-6.rs
use std::sync::Mutex;
<|fim_middle|>enum Foo { X(Mutex<Option<Foo>>) }
//~^ ERROR recursive type `Foo` has infinite size
| code_fim | medium | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/test/ui/issues/issue-17431-6.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: falconre/falconre path: /src/falcon/il/instruction.rs
use crate::map_err;
use pyo3::class::PyObjectProtocol;
use pyo3::prelude::*;
use super::Operation;
#[pyclass]
pub struct Instruction {
pub(crate) instruction: falcon::il::Instruction,
}
#[pymethods]
impl Instruction {
fn operation(... | code_fim | medium | {
"lang": "rust",
"repo": "falconre/falconre",
"path": "/src/falcon/il/instruction.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn address(&self) -> Option<u64> {
self.instruction.address()
}
fn json(&self) -> PyResult<String> {
map_err(serde_json::to_string(&self.instruction))
}
}
#[pyproto]
impl<'p> PyObjectProtocol<'p> for Instruction {
fn __str__(&self) -> PyResult<String> {
Ok(sel... | code_fim | medium | {
"lang": "rust",
"repo": "falconre/falconre",
"path": "/src/falcon/il/instruction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(self.instruction.to_string())
}
fn __repr__(&self) -> PyResult<String> {
Ok(self.instruction.to_string())
}
}
impl From<falcon::il::Instruction> for Instruction {
fn from(instruction: falcon::il::Instruction) -> Instruction {
Instruction { instruction }
}
}... | code_fim | medium | {
"lang": "rust",
"repo": "falconre/falconre",
"path": "/src/falcon/il/instruction.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: pkmn-api/pkmnapi path: /pkmnapi-api/src/routes/move_stats.rs
use pkmnapi_db::*;
use pkmnapi_sql::*;
use rocket::response::status;
use rocket::State;
use rocket_contrib::json::{Json, JsonError, JsonValue};
use rocket_okapi::openapi;
use crate::guards::*;
use crate::requests::move_stats::*;
use c... | code_fim | hard | {
"lang": "rust",
"repo": "pkmn-api/pkmnapi",
"path": "/pkmnapi-api/src/routes/move_stats.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[openapi]
#[post("/moves/stats/<move_id>", format = "application/json", data = "<data>")]
pub fn post_move_stats(
sql: State<PkmnapiSQL>,
_rate_limit: RateLimit,
access_token: Result<AccessToken, AccessTokenError>,
patch_description: Result<PatchDescription, PatchDescriptionError>,
da... | code_fim | hard | {
"lang": "rust",
"repo": "pkmn-api/pkmnapi",
"path": "/pkmnapi-api/src/routes/move_stats.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let move_stats = MoveStats {
move_id: move_id,
effect: data.get_effect(),
power: data.get_power(),
type_id: data.get_type_id(),
accuracy: data.get_accuracy(),
pp: data.get_pp(),
};
let patch = db.set_move_stats(&move_id, &move_stats)?;
util... | code_fim | hard | {
"lang": "rust",
"repo": "pkmn-api/pkmnapi",
"path": "/pkmnapi-api/src/routes/move_stats.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Get the underlying socket.
fn get_socket_dyn_ref(&self) -> &dyn AsyncSocket;
}
/// Get the underlying socket.
pub trait TlsStreamWithSocketDyn<S>: TlsStreamDyn {
/// Get the underlying socket.
fn get_socket_mut(&mut self) -> &mut S;
/// Get the underlying socket.
fn get_socke... | code_fim | medium | {
"lang": "rust",
"repo": "stepancheg/rust-tls-api",
"path": "/api/src/stream_dyn.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: stepancheg/rust-tls-api path: /api/src/stream_dyn.rs
use crate::AsyncSocket;
use crate::ImplInfo;
/// Trait implemented by all `TlsStream` objects.
///
/// Provide access to some TLS stream properties (only ALPN at the moment.)
pub trait TlsStreamDyn: AsyncSocket {
/// Get negotiated ALPN p... | code_fim | medium | {
"lang": "rust",
"repo": "stepancheg/rust-tls-api",
"path": "/api/src/stream_dyn.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Get the underlying socket.
pub trait TlsStreamWithSocketDyn<S>: TlsStreamDyn {
/// Get the underlying socket.
fn get_socket_mut(&mut self) -> &mut S;
/// Get the underlying socket.
fn get_socket_ref(&self) -> &S;
}
/// Interface upcast. This is an interface for API implementors.
pub ... | code_fim | medium | {
"lang": "rust",
"repo": "stepancheg/rust-tls-api",
"path": "/api/src/stream_dyn.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hybras/protonvpn path: /src/cli/initialize.rs
//! The functions in this module are expected to work. They have been tested by hand, but currently can't be tested programmatically because console doesn't have a testing functionality.
<|fim_suffix|>/// Asks for every setting and creates the app's... | code_fim | medium | {
"lang": "rust",
"repo": "hybras/protonvpn",
"path": "/src/cli/initialize.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(())
}
fn create_config_dir(pdir: &ProjectDirs) -> Result<()> {
create_dir(pdir.config_dir()).context("Failed to create app config dir")
}<|fim_prefix|>// repo: hybras/protonvpn path: /src/cli/initialize.rs
//! The functions in this module are expected to work. They have been tested by hand, but cur... | code_fim | hard | {
"lang": "rust",
"repo": "hybras/protonvpn",
"path": "/src/cli/initialize.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: playXE/garbage-collector path: /src/utils.rs
use core::cmp::Ordering;
use core::fmt;
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
#[repr(transparent)]
pub struct Address(usize);
impl Address {
#[inline(always)]
pub const fn from(val: usize) -> Address {
Address(val)
}
#[... | code_fim | hard | {
"lang": "rust",
"repo": "playXE/garbage-collector",
"path": "/src/utils.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let p = os::page_size();
assert_eq!(false, is_page_aligned(1));
assert_eq!(false, is_page_aligned(2));
assert_eq!(false, is_page_aligned(64));
assert_eq!(true, is_page_aligned(p));
assert_eq!(true, is_page_aligned(2 * p));
assert_eq!(true, is_page_a... | code_fim | hard | {
"lang": "rust",
"repo": "playXE/garbage-collector",
"path": "/src/utils.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lams3/raytracing-rust path: /src/hittables/hittable_list.rs
use crate::structures::{Point3, Ray, HitRecord, AABB};
use crate::hittables::Hittable;
use std::sync::Arc;
pub struct HittableList {
pub hittables: Vec<Arc<dyn Hittable>>
}
impl HittableList {
pub fn new() -> Self {
S... | code_fim | hard | {
"lang": "rust",
"repo": "lams3/raytracing-rust",
"path": "/src/hittables/hittable_list.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for hittable in &self.hittables {
match hittable.hit(ray, t_min, closest_so_far) {
Some(record) => {
closest_so_far = record.t;
current_hit = Some(record);
},
None => ()
}
}
... | code_fim | hard | {
"lang": "rust",
"repo": "lams3/raytracing-rust",
"path": "/src/hittables/hittable_list.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/librustc_save_analysis/lib.rs
et outputs = &*self.tcx.output_filenames(LOCAL_CRATE);
if outputs.outputs.contains_key(&OutputType::Metadata) {
filename_for_metadata(sess, crate_name, outputs)
} else if outputs.outputs.should_... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/librustc_save_analysis/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn lookup_def_id(&self, ref_id: NodeId) -> Option<DefId> {
match self.get_path_res(ref_id) {
Res::PrimTy(_) | Res::SelfTy(..) | Res::Err => None,
def => Some(def.def_id()),
}
}
fn docs_for_attrs(&self, attrs: &[Attribute]) -> String {
let mut re... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/librustc_save_analysis/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/librustc_save_analysis/lib.rs
lname.push_str(&self.tcx.hir().hir_to_pretty_string(ty.hir_id));
let trait_id = self.tcx.trait_id_of_impl(impl_id);
let mut decl_id = None;
... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/librustc_save_analysis/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Soma de min(k, d_i) de i = k+1 até n
let mut sum_min = 0_u64;
for j in k+1 ..= n {
let dj = sequence[j as usize - 1];
sum_min += k.min(dj);
}
if sum_di > (k*(k-1) + sum_min) {
return false;
}
}
true
}
fn mai... | code_fim | hard | {
"lang": "rust",
"repo": "vrmiguel/is_graphic",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (k, &di) in sequence.iter().enumerate() {
let k = k as u64 + 1;
sum_di += di;
// Soma de min(k, d_i) de i = k+1 até n
let mut sum_min = 0_u64;
for j in k+1 ..= n {
let dj = sequence[j as usize - 1];
sum_min += k.min(dj);
... | code_fim | medium | {
"lang": "rust",
"repo": "vrmiguel/is_graphic",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: vrmiguel/is_graphic path: /src/main.rs
fn is_sum_even(sequence: &mut Vec<u64>) -> bool {
let seq_sum: u64 = sequence.iter().sum();
seq_sum % 2 == 0
}
fn is_graphic(mut sequence: Vec<u64>) -> bool {
<|fim_suffix|>fn main() {
dbg!(is_graphic(vec![3,3,2,1,1,0]));
dbg!(is_graphic(vec!... | code_fim | hard | {
"lang": "rust",
"repo": "vrmiguel/is_graphic",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: syepes/rust-zbx path: /examples/dummy/src/lib.rs
// Example Zabbix loadable module written in Rust
#![feature(plugin)]
#![plugin(clippy)]
extern crate zbx;
extern crate rand;
use rand::Rng;
use std::{str, slice};
#[no_mangle]
pub extern "C" fn zbx_module_api_version() -> i32 { zbx::ZBX_MODULE... | code_fim | hard | {
"lang": "rust",
"repo": "syepes/rust-zbx",
"path": "/examples/dummy/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
#[allow(unused_variables)]
pub extern "C" fn zbx_module_history_write_cbs() -> zbx::ZBX_HISTORY_WRITE_CBS {
zbx::ZBX_HISTORY_WRITE_CBS { history_float_cb: Some(dummy_history_float_cb),
history_integer_cb: Some(dummy_history_integer_cb),
... | code_fim | hard | {
"lang": "rust",
"repo": "syepes/rust-zbx",
"path": "/examples/dummy/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[no_mangle]
#[allow(unused_variables)]
pub extern "C" fn rust_random(request: *mut zbx::AGENT_REQUEST, result: *mut zbx::AGENT_RESULT) -> i32 {
let mut rng = rand::thread_rng();
let num = rng.gen::<u64>();
zbx::AGENT_RESULT::set_uint64_result(result, num);
zbx::SYSINFO_RET_OK
}
#[no_m... | code_fim | hard | {
"lang": "rust",
"repo": "syepes/rust-zbx",
"path": "/examples/dummy/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andoriyu/material-design-icons-rs path: /src/materialiconssharp/action/icon_donut_large.rs
pub struct IconDonutLarge {
props: crate::Props,
}
impl yew::Component for IconDonutLarge {
type Properties = crate::Props;
type Message = ();
fn create(props: Self::Properties, _: yew::prelu... | code_fim | medium | {
"lang": "rust",
"repo": "andoriyu/material-design-icons-rs",
"path": "/src/materialiconssharp/action/icon_donut_large.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hsyang1222/rust_example_code path: /BOJ/1920/LJC_code.rs
/****************************************************************************************
Question)
N개의 수가 주어졌을 때, 이를 오름차순으로 정렬하는 프로그램을 작성하시오.
input)
첫째 줄에 수의 개수 N(1 ≤ N ≤ 1,000)이 주어진다. 둘째 줄부터 N개의 줄에는 수 주어진다.
이 수는 절댓값이 1,000보다 작거나 같은 정수... | code_fim | hard | {
"lang": "rust",
"repo": "hsyang1222/rust_example_code",
"path": "/BOJ/1920/LJC_code.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in (0..arr_len) {
let mut rand_num = rand::thread_rng().gen_range(-10000000, 10000001);
loop {
if arr.contains(&rand_num) {
rand_num = rand::thread_rng().gen_range(-10000000, 10000001);
} else {
arr.push(rand_num);
... | code_fim | hard | {
"lang": "rust",
"repo": "hsyang1222/rust_example_code",
"path": "/BOJ/1920/LJC_code.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<S> Message<S> {
pub(crate) fn new(state: State<S>, frame: Transfer, link: ReceiverLink) -> Self {
Message { state, frame, link }
}
pub fn state(&self) -> &S {
self.state.get_ref()
}
pub fn state_mut(&mut self) -> &mut S {
self.state.get_mut()
}
p... | code_fim | hard | {
"lang": "rust",
"repo": "avranju/ntex-amqp",
"path": "/src/server/message.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> From<T> for Outcome
where
T: Into<Error>,
{
fn from(err: T) -> Self {
Outcome::Error(err.into())
}
}
impl Outcome {
pub(crate) fn into_delivery_state(self) -> DeliveryState {
match self {
Outcome::Accept => DeliveryState::Accepted(Accepted {}),
... | code_fim | hard | {
"lang": "rust",
"repo": "avranju/ntex-amqp",
"path": "/src/server/message.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: avranju/ntex-amqp path: /src/server/message.rs
use std::fmt;
use bytes::Bytes;
use ntex_amqp_codec::protocol::{Accepted, DeliveryState, Error, Rejected, Transfer, TransferBody};
use ntex_amqp_codec::Decode;
use crate::rcvlink::ReceiverLink;
use crate::session::Session;
use super::{AmqpError, ... | code_fim | hard | {
"lang": "rust",
"repo": "avranju/ntex-amqp",
"path": "/src/server/message.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: strake/cela.rs path: /src/moore.rs
use self::Neighborhood::*;
#[inline]
fn reflect(x: u8) -> u8 { x.rotate_left(1).reverse_bits() }
#[inline]
pub(crate) fn isotropicize(x: u8) -> u8 {
(0..4).map(|k| ::core::cmp::min(x.rotate_left(k << 1), reflect(x).rotate_left(k << 1))).min().unwrap_or(x)... | code_fim | hard | {
"lang": "rust",
"repo": "strake/cela.rs",
"path": "/src/moore.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> N0 => N8,
N1c => N7c,
N1e => N7e,
N2c => N6c,
N2e => N6e,
N2k => N6k,
N2a => N6a,
N2i => N6i,
N2n => N6n,
N3c => N5c,
N3e => N5e,
N3k => N5k,
N3a => N5a,
N3i => N5i,
N3n => N5n,
... | code_fim | hard | {
"lang": "rust",
"repo": "strake/cela.rs",
"path": "/src/moore.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> diesel::insert_into(addresses)
.values(new_addresses)
.on_conflict((postcode, number))
.do_update()
.set((
lat.eq(excluded(lat)),
lon.eq(excluded(lon)),
street.eq(excluded(street)),
city.eq(excluded(city)),
reg... | code_fim | hard | {
"lang": "rust",
"repo": "LeonardBesson/Postcode-API",
"path": "/src/data/repo/addresses.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LeonardBesson/Postcode-API path: /src/data/repo/addresses.rs
use std::collections::HashMap;
use diesel::pg::upsert::excluded;
use diesel::prelude::*;
use uuid::Uuid;
use crate::data::models::{Address, AddressRecord, NewAddress};
use crate::db::Pool;
const ADDRESSES_RESULT_LIMIT: i64 = 200;
p... | code_fim | hard | {
"lang": "rust",
"repo": "LeonardBesson/Postcode-API",
"path": "/src/data/repo/addresses.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prisma/opentls path: /src/lib.rs
//! TLS streams using OpenSSL.
//!
//! This crate is meant for cases when it is important to use OpenSSL for the
//! TLS implementation, allowing vendoring on platforms other than Linux. In
//! many cases it is recommended to use the TLS facilities of the platfor... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/opentls",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> min: Option<Protocol>,
max: Option<Protocol>,
ctx: &mut SslContextBuilder,
) -> std::result::Result<(), ErrorStack> {
use openssl::ssl::SslOptions;
let no_ssl_mask = SslOptions::NO_SSLV2
| SslOptions::NO_SSLV3
| SslOptions::NO_TLSV1
| SslOptions::NO_TLSV1_1
... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/opentls",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(any(feature = "io-tokio", feature = "io-async-std"))]
#[cfg_attr(feature = "docs", doc(cfg(any(feature = "io-tokio", feature = "io-async-std"))))]
pub mod async_io;
pub mod sync_io;
mod certificate;
mod error;
mod identity;
pub use certificate::Certificate;
pub use error::{Error, HandshakeError};
... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/opentls",
"path": "/src/lib.rs",
"mode": "spm",
"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.