text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> assert_eq!(
pot_slice_to_string(next_state.as_slice()),
"...#..#.#..##......###...###..."
);
assert_eq!(i0, -3);
part1_step(&mut state, &mut next_state, ¬es, &mut i0);
assert_eq!(
... | code_fim | hard | {
"lang": "rust",
"repo": "nbigaouette/advent_of_code_2018",
"path": "/day12/src/initial.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn is_program_in_path(program: &str) -> bool {
if let Ok(path) = std::env::var("PATH") {
for p in path.split(":") {
let p_str = format!("{}/{}", p, program);
if std::fs::metadata(p_str).is_ok() {
return true;
}
}
}
false
}
fn deno_cmd() -> Com... | code_fim | hard | {
"lang": "rust",
"repo": "chances/deno-wgpu",
"path": "/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let gen_idl_err = String::from("failed to generate rust interfaces from WebGPU IDL");
let output = gen_idl.output().expect(gen_idl_err.as_str());
if output.status.code().expect("deno status code") != 0 {
println!("{}", std::str::from_utf8(&output.stdout).unwrap());
println!("{}", std::str::f... | code_fim | medium | {
"lang": "rust",
"repo": "chances/deno-wgpu",
"path": "/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chances/deno-wgpu path: /build.rs
use std::process::Command;
// Reference: https://doc.rust-lang.org/cargo/reference/build-script-examples.html#code-generation
// `cargo build -vv` to see debug output
<|fim_suffix|> gen_idl.args(&["run", "--allow-read", "--allow-write", "--allow-run", "script... | code_fim | medium | {
"lang": "rust",
"repo": "chances/deno-wgpu",
"path": "/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn deserialize_string(s: &mut String, buf: &mut &[u8]) {
for byte in buf.iter() {
if *byte == 0 { break; }
s.push(char::from_u32(*byte as u32).expect("deserialize_string: invalid character skipped"));
}
}
fn serialize_bool(b: bool, buf: &mut Vec<u8>) {
... | code_fim | hard | {
"lang": "rust",
"repo": "DanCrank/ground_control_rust",
"path": "/src/messages.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DanCrank/ground_control_rust path: /src/messages.rs
// message structures used by ground_control
use chrono::prelude::*;
use crate::errors::*;
use rfm69::{ Rfm69, registers::Registers };
use rppal::{ gpio::OutputPin, spi::Spi };
use std::{ thread };
use std::time::{ Duration, Instant };
const ... | code_fim | hard | {
"lang": "rust",
"repo": "DanCrank/ground_control_rust",
"path": "/src/messages.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> x as u8
}
#[inline(always)]
fn index(&self) -> usize {
*self as usize
}
#[inline(always)]
fn max() -> Self {
::std::u8::MAX
}
#[inline(always)]
fn zero() -> Self {
0
}
#[inline(always)]
fn one() -> Self {
1
}
}
//... | code_fim | hard | {
"lang": "rust",
"repo": "mneumann/graphrs",
"path": "/src/index_type.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mneumann/graphrs path: /src/index_type.rs
use std::fmt;
/// Code from https://github.com/bluss/petulant-avenger-graphlibrary/blob/master/src/graph.rs.
/// The default integer type for node and edge indices in `Graph`.
/// `u32` is the default to reduce the size of the graph's data and improve
... | code_fim | hard | {
"lang": "rust",
"repo": "mneumann/graphrs",
"path": "/src/index_type.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
// FIXME: These aren't stable, so a public wrapper of node/edge indices
// should be lifetimed just like pointers.
/// Node identifier.
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash)]
pub struct EdgeIndex<Ix = DefIndex>(Ix);
impl<Ix: IndexType = DefIndex> EdgeIndex<Ix>
{
#[inline... | code_fim | hard | {
"lang": "rust",
"repo": "mneumann/graphrs",
"path": "/src/index_type.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jeandudey/cc13x2-rs path: /src/aux_anaif/adcfifostat.rs
#[doc = "Reader of register ADCFIFOSTAT"]
pub type R = crate::R<u32, super::ADCFIFOSTAT>;
#[doc = "Writer for register ADCFIFOSTAT"]
pub type W = crate::W<u32, super::ADCFIFOSTAT>;
#[doc = "Register ADCFIFOSTAT `reset()`'s with value 0x01"]... | code_fim | hard | {
"lang": "rust",
"repo": "jeandudey/cc13x2-rs",
"path": "/src/aux_anaif/adcfifostat.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>bits & 0x01) != 0)
}
}
impl W {
#[doc = "Bits 5:31 - 31:5\\]
Software should not rely on the value of a reserved. Writing any other value than the reset value may result in undefined behavior."]
#[inline(always)]
pub fn reserved5(&mut self) -> RESERVED5_W {
RESERVED5_W { w: self }
... | code_fim | hard | {
"lang": "rust",
"repo": "jeandudey/cc13x2-rs",
"path": "/src/aux_anaif/adcfifostat.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: YoEight/googapis path: /googapis/genproto/google.cloud.asset.v1beta1.rs
/// Temporal asset. In addition to the asset, the temporal asset includes the
/// status of the asset and valid from and to time of it.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TemporalAsset {
/// The tim... | code_fim | hard | {
"lang": "rust",
"repo": "YoEight/googapis",
"path": "/googapis/genproto/google.cloud.asset.v1beta1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>le.com/apis/design/resource_names#full_resource_name)
/// for more info.
///
/// The request becomes a no-op if the asset name list is empty, and the max
/// size of the asset name list is 100 in one request.
#[prost(string, repeated, tag = "2")]
pub asset_names: ::std::vec::Vec<st... | code_fim | hard | {
"lang": "rust",
"repo": "YoEight/googapis",
"path": "/googapis/genproto/google.cloud.asset.v1beta1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: daiyanbao/tun2tor path: /src/tcp.rs
#![allow(dead_code)]
use packet::{PktBuf, MutPktBuf, Header, Pair, Checksum};
use ip::IpHeader;
#[derive(Debug)]
pub struct TcpHeader<T: AsRef<[u8]>> {
buf: T,
}
impl<T> Header<T> for TcpHeader<T>
where T: AsRef<[u8]>
{
fn with_buf(buf: T) -> Tc... | code_fim | hard | {
"lang": "rust",
"repo": "daiyanbao/tun2tor",
"path": "/src/tcp.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn is_syn(&self) -> bool {
(self.options() & 0x2) == 0x2
}
pub fn is_ack(&self) -> bool {
(self.options() & 0x10) == 0x10
}
pub fn is_fin(&self) -> bool {
(self.options() & 0x1) == 0x1
}
fn checksum(&self) -> u16 {
self.buf.read_u16(16)
... | code_fim | hard | {
"lang": "rust",
"repo": "daiyanbao/tun2tor",
"path": "/src/tcp.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let input = PathBuf::from("fixtures/day20c.txt");
let problem = Day20 { input };
assert_eq!(problem.part_two(), 396);
}
}<|fim_prefix|>// repo: matt-thomson/advent-of-code path: /2019/src/day20/mod.rs
mod maze;
use std::path::PathBuf;
use pathfinding::prelude::bfs;
use stru... | code_fim | hard | {
"lang": "rust",
"repo": "matt-thomson/advent-of-code",
"path": "/2019/src/day20/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matt-thomson/advent-of-code path: /2019/src/day20/mod.rs
mod maze;
use std::path::PathBuf;
use pathfinding::prelude::bfs;
use structopt::StructOpt;
use crate::problem::Problem;
use maze::Maze;
#[derive(Debug, StructOpt)]
pub struct Day20 {
#[structopt(parse(from_os_str))]
input: Pat... | code_fim | hard | {
"lang": "rust",
"repo": "matt-thomson/advent-of-code",
"path": "/2019/src/day20/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: beagleknight/fag-rust path: /src/physics.rs
use crate::sprite::Dimensions2D;
use crate::sprite::Sprite;
use crate::sprite::Vector2D;
pub fn sprite_collision(sprite_1: &mut Sprite, spr<|fim_suffix|>);
let x2_1 = x1_1 + w1;
let y2_1 = y1_1 + h1;
let Vector2D { x: x1_2, y: y1_2 } = sprite_2.... | code_fim | medium | {
"lang": "rust",
"repo": "beagleknight/fag-rust",
"path": "/src/physics.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> h2 } = sprite_2.size();
let x2_2 = x1_2 + w2;
let y2_2 = y1_2 + h2;
(x1_1 < x2_2) && (x2_1 > x1_2) && (y1_1 < y2_2) && (y2_1 > y1_2)
}<|fim_prefix|>// repo: beagleknight/fag-rust path: /src/physics.rs
use crate::sprite::Dimensions2D;
use crate::sprite::Sprite;
use crate::sprite::Vector2D;
pub fn ... | code_fim | hard | {
"lang": "rust",
"repo": "beagleknight/fag-rust",
"path": "/src/physics.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>);
let x2_1 = x1_1 + w1;
let y2_1 = y1_1 + h1;
let Vector2D { x: x1_2, y: y1_2 } = sprite_2.position();
let Dimensions2D { w: w2, h: h2 } = sprite_2.size();
let x2_2 = x1_2 + w2;
let y2_2 = y1_2 + h2;
(x1_1 < x2_2) && (x2_1 > x1_2) && (y1_1 < y2_2) && (y2_1 > y1_2)
}<|fim_prefix|>// repo: be... | code_fim | medium | {
"lang": "rust",
"repo": "beagleknight/fag-rust",
"path": "/src/physics.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ON_A> {
use crate::Variant::*;
match self.bits {
0 => Val(LOCATION_A::LOC0),
1 => Val(LOCATION_A::LOC1),
2 => Val(LOCATION_A::LOC2),
3 => Val(LOCATION_A::LOC3),
4 => Val(LOCATION_A::LOC4),
5 => Val(LOCATION_A::LOC5),
... | code_fim | hard | {
"lang": "rust",
"repo": "lucab/efm32hg-pac",
"path": "/src/timer0/route.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lucab/efm32hg-pac path: /src/timer0/route.rs
#[doc = "Reader of register ROUTE"]
pub type R = crate::R<u32, super::ROUTE>;
#[doc = "Writer for register ROUTE"]
pub type W = crate::W<u32, super::ROUTE>;
#[doc = "Register ROUTE `reset()`'s with value 0"]
impl crate::ResetValue for super::ROUTE {
... | code_fim | hard | {
"lang": "rust",
"repo": "lucab/efm32hg-pac",
"path": "/src/timer0/route.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: matter-labs/zksync path: /core/bin/zksync_api/src/api_server/rest/v02/mod.rs
// External uses
use actix_web::{
web::{self},
Scope,
};
// Workspace uses
use crate::api_server::rest::network_status::SharedNetworkStatus;
use zksync_api_types::v02::ApiVersion;
use zksync_config::ZkSyncConfig... | code_fim | hard | {
"lang": "rust",
"repo": "matter-labs/zksync",
"path": "/core/bin/zksync_api/src/api_server/rest/v02/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub(crate) fn api_scope(
tx_sender: TxSender,
zk_config: &ZkSyncConfig,
network_status: SharedNetworkStatus,
) -> Scope {
let data = SharedData {
net: zk_config.chain.eth.network,
api_version: ApiVersion::V02,
};
web::scope("/api/v0.2")
.app_data(web::Data::... | code_fim | hard | {
"lang": "rust",
"repo": "matter-labs/zksync",
"path": "/core/bin/zksync_api/src/api_server/rest/v02/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> mimicaw::run_tests(&args, tests, |_, test_fn: TestFn| {
let handle = test_fn();
async move { handle.await.unwrap() }
})
.await
.exit()
}<|fim_prefix|>// repo: isgasho/mimicaw path: /examples/tokio.rs
use mimicaw::{Args, Outcome, Test};
use tokio::task;
type TestFn = fn() ... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/mimicaw",
"path": "/examples/tokio.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: isgasho/mimicaw path: /examples/tokio.rs
use mimicaw::{Args, Outcome, Test};
use tokio::task;
type TestFn = fn() -> task::JoinHandle<Outcome>;
#[tokio::main]
async fn main() {
let args = Args::from_env().unwrap_or_else(|st| st.exit());
<|fim_suffix|> mimicaw::run_tests(&args, tests, |_... | code_fim | hard | {
"lang": "rust",
"repo": "isgasho/mimicaw",
"path": "/examples/tokio.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let remaining = initial_value;
let (response_type, remaining) = u8::try_parse(remaining)?;
let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
let (sequence, remaining) = u16::try_parse(remaining)?;
let (length, remaining) = u32::try_parse(remai... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/x11rb",
"path": "/src/protocol/xf86dri.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/x11rb path: /src/protocol/xf86dri.rs
troyDrawableRequest {
pub screen: u32,
pub drawable: u32,
}
impl DestroyDrawableRequest {
/// Serialize this request into bytes for the provided connection
fn serialize(self, major_opcode: u8) -> BufWithFds<PiecewiseBuf<'static>> {
... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/x11rb",
"path": "/src/protocol/xf86dri.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: iCodeIN/x11rb path: /src/protocol/xf86dri.rs
};
request0.send(conn)
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct CreateDrawableReply {
pub sequence: u16,
pub length: u32,
pub hw_drawable_handle: u32,
}
impl TryParse for CreateDrawableReply {
fn try_parse(initia... | code_fim | hard | {
"lang": "rust",
"repo": "iCodeIN/x11rb",
"path": "/src/protocol/xf86dri.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn same_group_category(a: char, b: char) -> bool {
match (classify_char(a), classify_char(b)) {
(CharCategory::Cjk, _) | (_, CharCategory::Cjk) => false,
(CharCategory::Separator(_), CharCategory::Separator(_)) => true,
(a, b) => a == b,
}
}
#[cfg(test)]
mod test {
use ... | code_fim | hard | {
"lang": "rust",
"repo": "jungbin-kwon/tokenizer",
"path": "/src/tokenizer/legacy_meilisearch.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jungbin-kwon/tokenizer path: /src/tokenizer/legacy_meilisearch.rs
use std::borrow::Cow;
use slice_group_by::StrGroupBy;
use super::{TokenStream, Tokenizer};
use crate::detection::classify_separator;
use crate::processors::ProcessedText;
use crate::token::SeparatorKind;
use crate::{Token, Token... | code_fim | hard | {
"lang": "rust",
"repo": "jungbin-kwon/tokenizer",
"path": "/src/tokenizer/legacy_meilisearch.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustAudio/dasp path: /dasp_sample/tests/conv.rs
}) => {
#[test]
fn test_to_u48() {
conv_cmps!(to_u48: U48, $($conv_cmps)*);
}
};
(to_u64 { $($conv_cmps:tt)* }) => {
#[test]
fn test_to_u64() {
conv_cmps!(to_u64, $($conv_cmp... | code_fim | hard | {
"lang": "rust",
"repo": "RustAudio/dasp",
"path": "/dasp_sample/tests/conv.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Test functions for wrapper sample types.
($T:ident: to_i8 { $($conv_cmps:tt)* }) => {
#[test]
fn test_to_i8() {
conv_cmps!($T; to_i8, $($conv_cmps)*);
}
};
($T:ident: to_i16 { $($conv_cmps:tt)* }) => {
#[test]
fn test_to_i16() {
... | code_fim | hard | {
"lang": "rust",
"repo": "RustAudio/dasp",
"path": "/dasp_sample/tests/conv.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RustAudio/dasp path: /dasp_sample/tests/conv.rs
for functions that convert to custom sample types (i.e. to_i24 converts to
/// `I24`).
macro_rules! test_fn {
(to_i8 { $($conv_cmps:tt)* }) => {
#[test]
fn test_to_i8() {
conv_cmps!(to_i8, $($conv_cmps)*);
... | code_fim | hard | {
"lang": "rust",
"repo": "RustAudio/dasp",
"path": "/dasp_sample/tests/conv.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VT-Tuzki/tornado-os path: /tornado-user/src/task.rs
// todo:重新整理
// 在用户的库中提供
/// 用户态任务
///
/// 目前只是暂时设计,将用户态任务硬编码在内核中
use alloc::sync::Arc;
use spin::Mutex;
use core::pin::Pin;
use alloc::boxed::Box;
use core::future::Future;
use core::sync::atomic::{AtomicUsize, Ordering};
use super::share... | code_fim | hard | {
"lang": "rust",
"repo": "VT-Tuzki/tornado-os",
"path": "/tornado-user/src/task.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub unsafe fn shared_task_handle(self: Arc<Self>) -> SharedTaskHandle {
SharedTaskHandle {
hart_id: 0,
// todo: 地址空间编号
address_space_id: self.asid,
task_ptr: Arc::into_raw(self) as usize
}
}
}
impl UserTask {
fn mark_ready(&self)... | code_fim | hard | {
"lang": "rust",
"repo": "VT-Tuzki/tornado-os",
"path": "/tornado-user/src/task.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl woke::Woke for UserTask {
fn wake_by_ref(task: &Arc<Self>) {
task.mark_ready();
}
}
/// 共享调度器返回的结果
#[derive(Debug)]
pub enum TaskResult {
/// 应当立即执行特定任务
Task(SharedTaskHandle),
/// 其它地址空间的任务要运行,应当让出时间片
ShouldYield(usize),
/// 队列已空,所有任务已经结束
Finished,
}<|fim_pre... | code_fim | hard | {
"lang": "rust",
"repo": "VT-Tuzki/tornado-os",
"path": "/tornado-user/src/task.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_serialization() {
for event in vec![
Message::Heartbeat,
Message::LoginRequest("test".to_string()),
Message::LoginResponse(123),
] {
let val = deserialize(&serialize(&event).... | code_fim | medium | {
"lang": "rust",
"repo": "0x65/sr",
"path": "/lib/src/message.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0x65/sr path: /lib/src/message.rs
use serde::{Deserialize, Serialize};
// TODO: document each event
#[derive(Serialize, Deserialize, PartialEq, Debug)]
pub enum Message {
Heartbeat,
LoginRequest(String),
LoginResponse(i64),
}
<|fim_suffix|>pub fn deserialize(bytes: &[u8]) -> Option... | code_fim | medium | {
"lang": "rust",
"repo": "0x65/sr",
"path": "/lib/src/message.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn deserialize(bytes: &[u8]) -> Option<Message> {
match bincode::deserialize(bytes) {
Ok(val) => Some(val),
Err(_) => None,
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_serialization() {
for event in vec![
Message::Heartbeat,
... | code_fim | medium | {
"lang": "rust",
"repo": "0x65/sr",
"path": "/lib/src/message.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xentrick/gssapi-rs path: /src/kadmin/testing/util/tcl_kadm5.rs
b"while parsing mkey_name name\x00"
as
*const u8
... | code_fim | hard | {
"lang": "rust",
"repo": "xentrick/gssapi-rs",
"path": "/src/kadmin/testing/util/tcl_kadm5.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: xentrick/gssapi-rs path: /src/kadmin/testing/util/tcl_kadm5.rs
bc::c_char,
mut out_policy: *mut kadm5_policy_ent_t)
-> libc::c_int {
let mut policy: kadm5_policy_ent_t = 0 as kadm5_policy_ent_t;
let mut tcl_ret: libc::c_int = 0;
let mut argc: li... | code_fim | hard | {
"lang": "rust",
"repo": "xentrick/gssapi-rs",
"path": "/src/kadmin/testing/util/tcl_kadm5.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>= 0;
static mut table: *mut Tcl_HashTable =
0 as *const Tcl_HashTable as *mut Tcl_HashTable;
let mut tcl_ret: libc::c_int = 0;
tcl_ret =
parse_flags(interp, table, principal_mask_flags.as_mut_ptr(),
(::std::mem::size_of::<[flagval; 20]>() as
... | code_fim | hard | {
"lang": "rust",
"repo": "xentrick/gssapi-rs",
"path": "/src/kadmin/testing/util/tcl_kadm5.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: InteractiveComputerGraphics/higher_order_embedded_fem path: /fenris/examples/poisson_common/mod.rs
use fenris::assembly::{GeneralizedEllipticContraction, GeneralizedEllipticOperator};
use nalgebra::allocator::Allocator;
use nalgebra::{DefaultAllocator, DimName, Matrix1, RealField, Scalar, Vector... | code_fim | hard | {
"lang": "rust",
"repo": "InteractiveComputerGraphics/higher_order_embedded_fem",
"path": "/fenris/examples/poisson_common/mod.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> gradient.clone_owned()
}
}
impl<T, GeometryDim> GeneralizedEllipticContraction<T, U1, GeometryDim> for PoissonEllipticOperator
where
T: RealField,
GeometryDim: DimName,
DefaultAllocator:
Allocator<T, GeometryDim, U1> + Allocator<T, GeometryDim, GeometryDim> + Allocator<T, ... | code_fim | hard | {
"lang": "rust",
"repo": "InteractiveComputerGraphics/higher_order_embedded_fem",
"path": "/fenris/examples/poisson_common/mod.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> // read config file in local directory
s.merge(File::with_name(".rrconfig")
.format(FileFormat::Yaml)
.required(false))?;
// add in settings from environment (with prefix "RR")
s.merge(Environment::with_prefix("rr"))?;
s.try_into().... | code_fim | hard | {
"lang": "rust",
"repo": "fsommer/redmine_remote",
"path": "/src/settings.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fsommer/redmine_remote path: /src/settings.rs
use config::{Config, Environment, File, FileFormat};
use errors::*;
<|fim_suffix|> // read config file in local directory
s.merge(File::with_name(".rrconfig")
.format(FileFormat::Yaml)
.required(false))... | code_fim | hard | {
"lang": "rust",
"repo": "fsommer/redmine_remote",
"path": "/src/settings.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // add in settings from environment (with prefix "RR")
s.merge(Environment::with_prefix("rr"))?;
s.try_into().chain_err(|| "Can't create settings from configuration")
}
}<|fim_prefix|>// repo: fsommer/redmine_remote path: /src/settings.rs
use config::{Config, Environment, Fil... | code_fim | hard | {
"lang": "rust",
"repo": "fsommer/redmine_remote",
"path": "/src/settings.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: FreddyWordingham/arc_fox path: /src/math/rng/distribution.rs
//! Distribution functions.
use rand::{rngs::ThreadRng, Rng};
<|fim_suffix|> if asym.abs() < 1.0e-6 {
return rng.gen_range(-1.0_f64, 1.0).acos();
}
((1.0 + asym.powi(2)
- ((1.0 - asym.powi(2)) / asym.mul_a... | code_fim | hard | {
"lang": "rust",
"repo": "FreddyWordingham/arc_fox",
"path": "/src/math/rng/distribution.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ((1.0 + asym.powi(2)
- ((1.0 - asym.powi(2)) / asym.mul_add(rng.gen_range(-1.0, 1.0), 1.0)).powi(2))
/ (2.0 * asym))
.acos()
}<|fim_prefix|>// repo: FreddyWordingham/arc_fox path: /src/math/rng/distribution.rs
//! Distribution functions.
use rand::{rngs::ThreadRng, Rng};
<|f... | code_fim | hard | {
"lang": "rust",
"repo": "FreddyWordingham/arc_fox",
"path": "/src/math/rng/distribution.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sammyne/optee-rs path: /src/allocator/mod.rs
use crate::libc;
use core::alloc::{GlobalAlloc, Layout};
use core::panic::PanicInfo;
// Bget allocator for *single* core systems
struct Bget {}
unsafe impl Sync for Bget {}
<|fim_suffix|> unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8... | code_fim | medium | {
"lang": "rust",
"repo": "sammyne/optee-rs",
"path": "/src/allocator/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>// #![feature(default_alloc_error_handler)] won't help.
#[alloc_error_handler]
fn handle_alloc_error(layout: Layout) -> ! {
panic!("alloction failed: {:?}", layout);
}<|fim_prefix|>// repo: sammyne/optee-rs path: /src/allocator/mod.rs
use crate::libc;
use core::alloc::{GlobalAlloc, Layout};
use core... | code_fim | hard | {
"lang": "rust",
"repo": "sammyne/optee-rs",
"path": "/src/allocator/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn file_exists(full_path: &Path) -> bool {
match fs::metadata(full_path) {
Err(_) => false,
Ok(f) => f.is_file(),
}
}
pub fn directory_exists(full_path: &Path) -> bool {
match fs::metadata(full_path) {
Err(_) => false,
Ok(f) => f.is_dir(),
}
}<|fim_prefi... | code_fim | medium | {
"lang": "rust",
"repo": "nunogrl/hookshot",
"path": "/src/verified_path.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nunogrl/hookshot path: /src/verified_path.rs
use error::Error;
use std::fs;
use std::path::Path;
use std::string::ToString;
#[derive(Debug, Clone)]
pub struct VerifiedPath {
path: String,
}
// TODO: refactor this, it's basically 80% copypasta
impl VerifiedPath {
pub fn file(root: Optio... | code_fim | medium | {
"lang": "rust",
"repo": "nunogrl/hookshot",
"path": "/src/verified_path.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: openstax/adaptarr-server path: /crates/cli/src/main.rs
fn main() {
if let Err(err) = adaptarr_cli::main() {
eprintln!("Error: {}", err);
<|fim_suffix|> eprintln!("{}", err.backtrace());
}
}<|fim_middle|> for cause in err.iter_causes() {
eprintln!("Cause... | code_fim | medium | {
"lang": "rust",
"repo": "openstax/adaptarr-server",
"path": "/crates/cli/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> eprintln!("{}", err.backtrace());
}
}<|fim_prefix|>// repo: openstax/adaptarr-server path: /crates/cli/src/main.rs
fn main() {
if let Err(err) = adaptarr_cli::main() {
eprintln!("Error: {}", err);
<|fim_middle|> for cause in err.iter_causes() {
eprintln!("Cause... | code_fim | medium | {
"lang": "rust",
"repo": "openstax/adaptarr-server",
"path": "/crates/cli/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mgx0612/lottox path: /src/lotto5/star3/star3_straight_single.rs
use common::sum::Sum;
use lotto5;
pub struct Star3StraightSingle {
lists: Vec<Vec<u8>>,
total: usize,
}
impl Sum for Star3StraightSingle {
fn sum(&self) -> usize {
self.total
}
}
impl Star3StraightSingle {... | code_fim | medium | {
"lang": "rust",
"repo": "mgx0612/lottox",
"path": "/src/lotto5/star3/star3_straight_single.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let r = Star3StraightSingle::init(vec![]);
assert!(r.is_none());
}
#[test]
fn test_bingo() {
let r = Star3StraightSingle::init(vec![vec![1, 2, 3], vec![1, 2, 4]]);
let r = r.unwrap().bingo(&[1, 2, 3, 4, 5], lotto5fst3);
assert!(r);
}
}<|fim_prefix|>... | code_fim | hard | {
"lang": "rust",
"repo": "mgx0612/lottox",
"path": "/src/lotto5/star3/star3_straight_single.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let r = Star3StraightSingle::init(vec![vec![1, 2, 3], vec![1, 2, 3]]);
assert!(r.is_none());
let r = Star3StraightSingle::init(vec![vec![1, 2, 3], vec![1, 2, 4]]);
assert!(r.is_some());
assert_eq!(r.unwrap().sum(), 2);
let r = Star3StraightSingle::init(vec!... | code_fim | hard | {
"lang": "rust",
"repo": "mgx0612/lottox",
"path": "/src/lotto5/star3/star3_straight_single.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mod attributes;
pub mod session;
mod features;
mod into_model;
mod scope;
pub mod translated;
pub use self::session::{Session, Packages};
pub use self::translated::Translated;<|fim_prefix|>// repo: nezdolik/reproto path: /lib/trans/lib.rs
extern crate linked_hash_map;
#[macro_use]
extern crate log;
exte... | code_fim | medium | {
"lang": "rust",
"repo": "nezdolik/reproto",
"path": "/lib/trans/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nezdolik/reproto path: /lib/trans/lib.rs
extern crate linked_hash_map;
#[macro_use]
extern crate log;
extern crate reproto_ast as ast;
extern crate reproto_core as core;
extern crate reproto_naming as naming;
extern crate reproto_parser as parser;
extern crate reproto_path_parser as path_parser;... | code_fim | hard | {
"lang": "rust",
"repo": "nezdolik/reproto",
"path": "/lib/trans/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if $diag.has_errors() {
return Err(());
}
}};
}
mod attributes;
pub mod session;
mod features;
mod into_model;
mod scope;
pub mod translated;
pub use self::session::{Session, Packages};
pub use self::translated::Translated;<|fim_prefix|>// repo: nezdolik/reproto path: /l... | code_fim | hard | {
"lang": "rust",
"repo": "nezdolik/reproto",
"path": "/lib/trans/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sudowork/adventofcode path: /2020/08-handheld/src/main.rs
use std::collections::HashSet;
#[derive(Copy, Clone)]
enum Instruction {
Acc(isize),
Jmp(isize),
Nop(isize),
}
fn main() {
let input_file = util::get_input_file("./input.txt");
let input = util::read_lines(input_file... | code_fim | hard | {
"lang": "rust",
"repo": "sudowork/adventofcode",
"path": "/2020/08-handheld/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut new_instructions = vec![];
new_instructions.extend_from_slice(&instructions[..pointer]);
match instructions[pointer] {
Instruction::Jmp(offset) => new_instructions.push(Instruction::Nop(offset)),
Instruction::Nop(offset) => new_instructions.push(Instruction::Nop(offset)... | code_fim | hard | {
"lang": "rust",
"repo": "sudowork/adventofcode",
"path": "/2020/08-handheld/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn string_to_key_id(&self) -> u8 {
match self {
SecretParams::Plain(k) => k.string_to_key_id(),
SecretParams::Encrypted(k) => k.string_to_key_id(),
}
}
pub fn compare_checksum(&self, other: Option<&[u8]>) -> Result<()> {
match self {
... | code_fim | hard | {
"lang": "rust",
"repo": "wking/cincinnati",
"path": "/vendor/pgp/src/types/params/secret.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: wking/cincinnati path: /vendor/pgp/src/types/params/secret.rs
use std::io;
use nom::{be_u8, rest_len};
use num_traits::FromPrimitive;
use zeroize::Zeroize;
use crate::crypto::public_key::PublicKeyAlgorithm;
use crate::crypto::sym::SymmetricKeyAlgorithm;
use crate::errors::Result;
use crate::se... | code_fim | hard | {
"lang": "rust",
"repo": "wking/cincinnati",
"path": "/vendor/pgp/src/types/params/secret.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn checksum(&self) -> Option<Vec<u8>> {
match self {
SecretParams::Plain(k) => Some(k.checksum_simple()),
SecretParams::Encrypted(k) => k.checksum(),
}
}
}
impl Serialize for SecretParams {
fn to_writer<W: io::Write>(&self, writer: &mut W) -> Result... | code_fim | hard | {
"lang": "rust",
"repo": "wking/cincinnati",
"path": "/vendor/pgp/src/types/params/secret.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>isplay());
println!("cargo:rerun-if-changed=build.rs");
}<|fim_prefix|>// repo: steamroller-airmash/luajit-rs path: /build.rs
extern crate cmake;
pub fn main() {
let path = cmake::b<|fim_middle|>uild("luajit");
println!("cargo:rustc-link-lib=luajit");
println!("cargo:rustc-link-search=native={}... | code_fim | medium | {
"lang": "rust",
"repo": "steamroller-airmash/luajit-rs",
"path": "/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
println!("cargo:rustc-link-search=native={}/lib", path.display());
println!("cargo:rerun-if-changed=build.rs");
}<|fim_prefix|>// repo: steamroller-airmash/luajit-rs path: /build.rs
extern crate cmake;
pub fn main() {
let path = cmake::b<|fim_middle|>uild("luajit");
println!("cargo:rustc-link-... | code_fim | easy | {
"lang": "rust",
"repo": "steamroller-airmash/luajit-rs",
"path": "/build.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: steamroller-airmash/luajit-rs path: /build.rs
extern crate cmake;
pub fn main() {
let path = cmake::b<|fim_suffix|>
println!("cargo:rustc-link-search=native={}/lib", path.display());
println!("cargo:rerun-if-changed=build.rs");
}<|fim_middle|>uild("luajit");
println!("cargo:rustc-link-... | code_fim | easy | {
"lang": "rust",
"repo": "steamroller-airmash/luajit-rs",
"path": "/build.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Desmonddai583/Notes path: /Rust/cxyjt/basic/demo/brainfuck/src/main_jit.rs
use std::io::prelude::*;
use dynasm::dynasm;
use dynasmrt::{DynasmApi, DynasmLabelApi};
mod opcode;
mod ir_code;
use ir_code::IR;
unsafe extern "sysv64" fn putchar(char: u8) {
std::io::stdout().write_all(&[char]).u... | code_fim | hard | {
"lang": "rust",
"repo": "Desmonddai583/Notes",
"path": "/Rust/cxyjt/basic/demo/brainfuck/src/main_jit.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // 对 ops 对象调用 finalize 后才会实际分配内存
let exec_buffer = ops.finalize().unwrap();
// 给 Brainfuck 源码执行时所使用的内存
let mut memory: Box<[u8]> = vec![0; 65536].into_boxed_slice();
// 内存起始地址
let memory_addr_from = memory.as_mut_ptr();
// 内存结束地址
let memory_a... | code_fim | hard | {
"lang": "rust",
"repo": "Desmonddai583/Notes",
"path": "/Rust/cxyjt/basic/demo/brainfuck/src/main_jit.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LcpMarvel/chinese_pinyin_rs path: /src/lib.rs
extern crate chinese_pinyin;
extern crate libc;
use libc::c_char;
use std::ffi::CStr;
use std::ffi::CString;
#[no_mangle]
pub extern "C" fn translate(characters: *const c_char, splitter: *const c_char, tonemarks: bool, tone: bool, camel: bool) -> *... | code_fim | hard | {
"lang": "rust",
"repo": "LcpMarvel/chinese_pinyin_rs",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let characters_str = std::str::from_utf8(c_characters.to_bytes()).unwrap();
let splitter_str = std::str::from_utf8(c_splitter.to_bytes()).unwrap();
let mut args = chinese_pinyin::Args::new();
args.splitter = splitter_str.to_string();
args.tonemarks = tonemarks;
args.tone = tone;
args.camel = came... | code_fim | medium | {
"lang": "rust",
"repo": "LcpMarvel/chinese_pinyin_rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let result = chinese_pinyin::translate(characters_str, &args);
let c_result = CString::new(result).unwrap();
c_result.into_raw()
}<|fim_prefix|>// repo: LcpMarvel/chinese_pinyin_rs path: /src/lib.rs
extern crate chinese_pinyin;
extern crate libc;
use libc::c_char;
use std::ffi::CStr;
use std::ffi::C... | code_fim | hard | {
"lang": "rust",
"repo": "LcpMarvel/chinese_pinyin_rs",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: MichalObi/sorting-visualization-rust-canvas path: /rust-sorting/src/lib.rs
extern crate js_sys;
extern crate wasm_bindgen;
extern crate wasm_bindgen_test;
extern crate web_sys;
use js_sys::{Array, Object, Reflect};
use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;
use web_sys::console;
m... | code_fim | hard | {
"lang": "rust",
"repo": "MichalObi/sorting-visualization-rust-canvas",
"path": "/rust-sorting/src/lib.rs",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> let first_index: JsValue = JsValue::from(0);
let second_index: JsValue = JsValue::from(1);
let third_index: JsValue = JsValue::from(2);
let fourth_index: JsValue = JsValue::from(3);
let values: Array = Object::values(&config);
let algo_type = Reflect::get(&values, &first_index).un... | code_fim | hard | {
"lang": "rust",
"repo": "MichalObi/sorting-visualization-rust-canvas",
"path": "/rust-sorting/src/lib.rs",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tweber12/rulac path: /src/math_expr/eval.rs
use crate::math_expr::parse::{parse_math, ParseError};
use crate::math_expr::{
BinaryOperator, Comparison, ComparisonOperator, Function, MathExpr, MathExprPlain, Number,
Tensor, UnaryOperator,
};
use crate::ufo::param_card::ParamCard;
use crate... | code_fim | hard | {
"lang": "rust",
"repo": "tweber12/rulac",
"path": "/src/math_expr/eval.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
eval_ufo_math(&UfoMath("cmath.cos(1/2.)".to_string()), &EvalContext::new()).unwrap(),
Number::from(0.5_f64.cos())
);
}
#[test]
fn one_equal_one() {
assert_eq!(
eval_ufo_math(
&UfoMath("4 if 1==1 else -4".t... | code_fim | hard | {
"lang": "rust",
"repo": "tweber12/rulac",
"path": "/src/math_expr/eval.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn load_parameters_restricted() {
let model = UfoModel::load("tests/models_json/sm_mg5").unwrap();
let restrict = ParamCard::read(&"tests/models/sm_mg5/restrict_default.dat").unwrap();
let context = EvalContext::from_restricted_model(&model, &restrict).unwrap();
... | code_fim | hard | {
"lang": "rust",
"repo": "tweber12/rulac",
"path": "/src/math_expr/eval.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: peterschwarz/diesel path: /diesel_cli/tests/print_schema/print_schema_regression_test_for_2623/sqlite/expected.rs
// @generated automatically by Diesel CLI.
diesel::table! {
tab_key1 (id) {
id -> Integer,
}
}
<|fim_suffix|>diesel::allow_tables_to_appear_in_same_query!(
tab_... | code_fim | medium | {
"lang": "rust",
"repo": "peterschwarz/diesel",
"path": "/diesel_cli/tests/print_schema/print_schema_regression_test_for_2623/sqlite/expected.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>diesel::table! {
tab_problem (id) {
id -> Integer,
key1 -> BigInt,
}
}
diesel::joinable!(tab_problem -> tab_key1 (key1));
diesel::allow_tables_to_appear_in_same_query!(
tab_key1,
tab_problem,
);<|fim_prefix|>// repo: peterschwarz/diesel path: /diesel_cli/tests/print_sche... | code_fim | medium | {
"lang": "rust",
"repo": "peterschwarz/diesel",
"path": "/diesel_cli/tests/print_schema/print_schema_regression_test_for_2623/sqlite/expected.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andy128k/simplex-rs path: /src/simplex.rs
Set::new();
let mut slack_variables = BTreeSet::new();
let mut surplus_variables = BTreeSet::new();
for var in goal.coeffs.keys() {
normal_variables.insert(*var);
}
for constraint in constraints {
for var in constraint... | code_fim | hard | {
"lang": "rust",
"repo": "andy128k/simplex-rs",
"path": "/src/simplex.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: andy128k/simplex-rs path: /src/simplex.rs
raint],
) -> (Vec<Variable>, Vec<Variable>, Vec<Variable>) {
let mut normal_variables = BTreeSet::new();
let mut slack_variables = BTreeSet::new();
let mut surplus_variables = BTreeSet::new();
for var in goal.coeffs.keys() {
norma... | code_fim | hard | {
"lang": "rust",
"repo": "andy128k/simplex-rs",
"path": "/src/simplex.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn set_goal_value(&mut self, goal_value: Rational32) {
let last_column = self.width() - 1;
self.values[0][last_column] = goal_value;
}
fn run(&mut self, start_row: usize) -> bool {
loop {
if let Some(pivot_column) = self.find_pivot_column(start_row) {
... | code_fim | hard | {
"lang": "rust",
"repo": "andy128k/simplex-rs",
"path": "/src/simplex.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shaoxp/hello_rust path: /art/src/lib.rs
//! # Art
//! A library for modeling artistics concepts
//!
pub use self::kinds::PrimaryColor;
pub use self::kinds::SecondaryColor;
pub use self::utils::mix;
<|fim_suffix|> /// The Second color according to RYB color model
pub enum SecondaryColor... | code_fim | medium | {
"lang": "rust",
"repo": "shaoxp/hello_rust",
"path": "/art/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub mod utils{
use crate::kinds::*;
/// Combine two primrary colors in equal ammount to create
/// a second color.
pub fn mix(c1:PrimaryColor,c2:PrimaryColor) -> SecondaryColor{
SecondaryColor::Orange
}
pub fn hello()->&'static str{
"hello"
}
}<|fim_prefi... | code_fim | hard | {
"lang": "rust",
"repo": "shaoxp/hello_rust",
"path": "/art/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Combine two primrary colors in equal ammount to create
/// a second color.
pub fn mix(c1:PrimaryColor,c2:PrimaryColor) -> SecondaryColor{
SecondaryColor::Orange
}
pub fn hello()->&'static str{
"hello"
}
}<|fim_prefix|>// repo: shaoxp/hello_rust path: /art/src... | code_fim | medium | {
"lang": "rust",
"repo": "shaoxp/hello_rust",
"path": "/art/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shory152/queue path: /spsc/rust/spsc2.rs
use std::sync::{Mutex, Condvar, Arc};
use std::{mem, ptr};
use std::alloc::Layout;
use std::sync::atomic::{AtomicUsize, Ordering};
pub trait SenderI<T> {
fn send(&self, e :T);
}
pub trait ReceiverI<T> {
fn recv(&self) -> T;
}
pub struct Sender<T>... | code_fim | hard | {
"lang": "rust",
"repo": "shory152/queue",
"path": "/spsc/rust/spsc2.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.count.load(Ordering::SeqCst) == 0 {
let g = self.sem_elem.0.lock().unwrap();
if self.count.load(Ordering::SeqCst) == 0 {
self.sem_elem.1.wait(g);
}
}
let e = self.get_elem();
let c = self.count.fetch_sub(1, Orderin... | code_fim | hard | {
"lang": "rust",
"repo": "shory152/queue",
"path": "/spsc/rust/spsc2.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prisma/prisma-engines path: /query-engine/core/src/interpreter/expressionista.rs
else(|| panic!("Node content {} was empty", node.id()))
{
Node::Query(_) => Self::build_query_expression(graph, node, parent_edges),
Node::Flow(_) => Self::build_flow_expression(graph... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/core/src/interpreter/expressionista.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: prisma/prisma-engines path: /query-engine/core/src/interpreter/expressionista.rs
r,
};
use crate::{query_graph::*, Query};
use std::{collections::VecDeque, convert::TryInto};
pub(crate) struct Expressionista;
/// Helper accumulator struct.
#[derive(Default)]
struct IfNodeAcc {
then: Option... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/core/src/interpreter/expressionista.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let node_id = node.id();
let node = graph.pluck_node(node);
let into_expr = Box::new(move |node: Node| {
let flow: Flow = node.try_into()?;
if let Flow::If(cond_fn) = flow {
let if_expr = Expression::If {
func: cond_fn,
... | code_fim | hard | {
"lang": "rust",
"repo": "prisma/prisma-engines",
"path": "/query-engine/core/src/interpreter/expressionista.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: brooks-builds/flocking_rust path: /src/systems/update_rotations.rs
use bbecs::components::CastComponents;
use bbecs::data_types::point::Point;
use bbecs::world::World;
use crate::component_names::ComponentNames;
<|fim_suffix|> rotations
.iter_mut()
.enumerate()
.for_... | code_fim | hard | {
"lang": "rust",
"repo": "brooks-builds/flocking_rust",
"path": "/src/systems/update_rotations.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> rotations
.iter_mut()
.enumerate()
.for_each(|(index, rotation)| {
let velocity = velocities[index];
*rotation = velocity.rotation();
});
}<|fim_prefix|>// repo: brooks-builds/flocking_rust path: /src/systems/update_rotations.rs
use bbecs::comp... | code_fim | hard | {
"lang": "rust",
"repo": "brooks-builds/flocking_rust",
"path": "/src/systems/update_rotations.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub use covenant::*;
pub use lockingscript::*;
pub use script::*;
pub use tx::*;
pub use txin::*;
pub use txout::*;<|fim_prefix|>// repo: radicle-dev/bitcoins-rs path: /handshakes/src/types/mod.rs
//! Holds Handshake specific types, witnesses, inputs, outputs, and transactions.
<|fim_middle|>pub mod cov... | code_fim | medium | {
"lang": "rust",
"repo": "radicle-dev/bitcoins-rs",
"path": "/handshakes/src/types/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: radicle-dev/bitcoins-rs path: /handshakes/src/types/mod.rs
//! Holds Handshake specific types, witnesses, inputs, outputs, and transactions.
<|fim_suffix|>pub use covenant::*;
pub use lockingscript::*;
pub use script::*;
pub use tx::*;
pub use txin::*;
pub use txout::*;<|fim_middle|>pub mod cov... | code_fim | medium | {
"lang": "rust",
"repo": "radicle-dev/bitcoins-rs",
"path": "/handshakes/src/types/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub unsafe fn g_object_ref_sink(object: glib::gpointer) -> glib::gpointer {
#[fixed_stack_segment]; #[inline(never)];
assert!(ptr::is_not_null(object));
native::g_object_ref_sink(object)
}
pub unsafe fn g_object_unref(object: glib::gpointer) {
#[fixed_stack_segment]; #[inline(never)];
... | code_fim | hard | {
"lang": "rust",
"repo": "cadencemarseille/rust-gobject",
"path": "/src/gobject/detail/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cadencemarseille/rust-gobject path: /src/gobject/detail/mod.rs
// Copyright 2013 The rust-gobject authors.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/M... | code_fim | hard | {
"lang": "rust",
"repo": "cadencemarseille/rust-gobject",
"path": "/src/gobject/detail/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let message_type = get_type(&mut vec);
match node.controllers.get(&message_type) {
None => (),
Some(c) => c.send(vec).unwrap(),
};
});
let _write_to_sck = thread::spawn(move || {
let mut push_sockets: HashMap... | code_fim | hard | {
"lang": "rust",
"repo": "ZePedroResende/cram",
"path": "/src/node/io/mod.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.