blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
1a45e5a1003db12f141639d35da67999edb2467c | Rust | wfraser/fuse-mt | /example/src/libc_extras.rs | UTF-8 | 7,172 | 2.5625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // libc_extras :: Functions missing from the libc crate and wrappers for better cross-platform
// compatibility.
//
// Copyright (c) 2016-2017 by William R. Fraser
//
pub mod libc {
#![allow(non_camel_case_types)]
pub use ::libc::*;
// stuff missing from the libc crate.
extern "system"... | true |
d9e25298effc7bde9728ec15aff464abebfe81dc | Rust | Kixiron/kugelblitz.rs | /src/commands/general/ping.rs | UTF-8 | 1,272 | 2.640625 | 3 | [] | no_license | use crate::commands::command_prelude::*;
#[command]
fn ping(ctx: &mut Context, msg: &Message) -> CommandResult {
let data = ctx.data.read();
let shard_manager = match data.get::<crate::data::ShardManagerContainer>() {
Some(v) => Ok(v),
None => {
msg.channel_id
.say(... | true |
5e7704687b5a8244ec60f14532276e5b3d719cc5 | Rust | alexcrichton/wasmtime | /crates/wasmtime/src/component/values.rs | UTF-8 | 40,323 | 2.96875 | 3 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | use crate::component::func::{Lift, Lower, Memory, MemoryMut, Options};
use crate::component::types::{self, Type};
use crate::store::StoreOpaque;
use crate::{AsContextMut, StoreContextMut, ValRaw};
use anyhow::{anyhow, bail, Context, Error, Result};
use std::collections::HashMap;
use std::fmt;
use std::iter;
use std::me... | true |
a035567b92928802068554e8653853debd7a547c | Rust | rayrobdod/png-inflate | /tests/truncate.rs | UTF-8 | 1,364 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | //! Asserts that, when the dut writes to an output file, that output file is truncated
extern crate png_inflate_derive;
extern crate tempfile;
use png_inflate_derive::generate_for_each_files;
use std::path::Path;
use std::process::Command;
use tempfile::NamedTempFile;
const PROGRAM_EXE: &str = env!("CARGO_BIN_EXE_pn... | true |
37391974fc01dd06c872aace51bca16132f7f36d | Rust | garmede/lotto_percentage | /src/main.rs | UTF-8 | 2,532 | 3.21875 | 3 | [] | no_license | use rand::prelude::*;
use std::time::{SystemTime, UNIX_EPOCH};
fn main() {
const SIMUL_COUNT: i32 = 10000000;
// 843회차 당첨 번호
let lotto_num = vec![19, 32, 37, 40, 41, 43];
let lotto_bonus = 45;
let sys_time = SystemTime::now()
.duration_since(UNIX_EPOCH)
.expect("Clock may have gone... | true |
4f2fb61b0dd7640b40f79c2e71e6b2da37934404 | Rust | mmai/webtarot | /tarotgame/src/bid.rs | UTF-8 | 10,229 | 3.3125 | 3 | [] | no_license | //! Auctions and bidding during the first phase of the deal.
use std::fmt;
use std::str::FromStr;
use serde::{Deserialize, Serialize};
use strum_macros::EnumIter;
use super::cards;
use super::deal;
use super::pos;
/// Goal set by a contract.
///
/// Determines the winning conditions and the score on success.
#[deriv... | true |
469e8c8447c1380ac1acab4203d5872e14c3971f | Rust | goodbin/advent-of-code | /2020/src/bin/day6.rs | UTF-8 | 1,234 | 3.140625 | 3 | [] | no_license | use adventofcode::*;
use std::collections::HashSet;
use std::str::FromStr;
const INPUT_FILE: &str = "inputs/day6.txt";
#[derive(Debug)]
struct Group {
persons: Vec<HashSet<char>>,
}
impl FromStr for Group {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let persons = s.split... | true |
fda7d9c4999e5b4a6b8e65e6bfafbf9084a0cc92 | Rust | evq/embedded-graphics | /embedded-graphics/src/primitives/triangle.rs | UTF-8 | 14,982 | 3.046875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! The triangle primitive.
use super::super::drawable::*;
use super::super::transform::*;
use crate::coord::{Coord, ToUnsigned};
use crate::pixelcolor::PixelColor;
use crate::primitives::line::{Line, LineIterator};
use crate::primitives::Primitive;
use crate::style::Style;
use crate::style::WithStyle;
use crate::unsi... | true |
6421cabe63fdff9101442ee9945e1bb2f92f4b24 | Rust | mukundbhudia/rs-challenges | /tests/x_and_o.rs | UTF-8 | 935 | 3.984375 | 4 | [] | no_license | // From: https://www.codewars.com/kata/55908aad6620c066bc00002a/train/rust
// Check to see if a string has the same amount of 'x's and 'o's.
// The method must return a boolean and be case insensitive.
// The string can contain any char.
pub fn xo(string: &'static str) -> bool {
string
.chars()
.f... | true |
8b9cf56ebf97b8314881537ff0f9ff25e737c978 | Rust | djk121/fitparse | /src/bin/dump_raw_records.rs | UTF-8 | 930 | 2.578125 | 3 | [] | no_license | extern crate clap;
extern crate fitparse;
extern crate itertools;
use clap::{App, Arg};
use std::fs::File;
use fitparse::fitfile::FitFile;
fn main() {
let matches = App::new("dfr")
.version("0.1")
.about("maybe parses fit files")
.author("djk121@gmail.com")
.arg(
Arg::... | true |
8bf244b58adc5f81f22cc9feb8cc8fcf58c17c64 | Rust | chwjbn/phala-blockchain | /crates/crypto/src/secp256k1.rs | UTF-8 | 3,262 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | use crate::{ecdh::EcdhKey, CryptoError};
use alloc::{vec, vec::Vec};
use ring::hkdf;
use sp_core::{ecdsa, Pair};
pub type Signature = ecdsa::Signature;
const SEED_BYTES: usize = 32;
type Seed = [u8; SEED_BYTES];
pub trait Signing {
fn sign_data(&self, data: &[u8]) -> Signature;
fn verify_data(&self, sig: &S... | true |
bd86e4b916eb269b2eaa2ae418b80308dbf336ca | Rust | littleroys/leetcode-rs | /src/array/word_search.rs | UTF-8 | 649 | 3.5 | 4 | [] | no_license | // #79 word search
struct Solution;
impl Solution {
pub fn exist(board: Vec<Vec<char>>, word: String) -> bool {
let idx = 0;
for row in board {
for ch in row {}
}
true
}
}
#[cfg(test)]
mod test {
use crate::array::word_search::Solution;
#[test]
pub fn ... | true |
bbd4178ddc34af3684b230c13309efc48c167541 | Rust | ryanhossain9797/rustling | /core/src/builder.rs | UTF-8 | 13,453 | 2.703125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::helpers::BoundariesChecker;
use crate::rule::{
Rule, Rule1, Rule2, Rule3, Rule4, Rule5, Rule6, RuleProductionArg, RuleResult, TerminalRule,
};
use crate::{
cell, pattern, CoreResult, NodePayload, Pattern, RuleSet, StashIndexable, Sym, SymbolTable,
TerminalPattern,
};
pub struct RuleSetBuilder<St... | true |
2b121a7def5853f540b6e2f35c9b33a6695fa0f8 | Rust | EmbarkStudios/rust-gpu | /crates/rustc_codegen_spirv-types/src/compile_result.rs | UTF-8 | 4,585 | 3.03125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::fmt::Write;
use std::path::{Path, PathBuf};
#[derive(Debug, Serialize, Deserialize)]
#[serde(untagged)]
pub enum ModuleResult {
SingleModule(PathBuf),
MultiModule(BTreeMap<String, PathBuf>),
}
impl ModuleResult {
pub fn unwrap_s... | true |
6a7adc8576edff50e32e76a7b59a724062a2b333 | Rust | AmaranthineCodices/whimsy | /src/cli.rs | UTF-8 | 822 | 2.78125 | 3 | [
"MIT"
] | permissive | use std::path::PathBuf;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
pub enum CliCommand {
#[structopt(
name = "open-cfg",
about = "Opens the whimsy configuration file in the default text editor for YAML files."
)]
OpenConfigFile,
#[structopt(
name = "regenerate-cfg",
... | true |
8f1b8625391cd083dbd796059360b54854484505 | Rust | yvt/enumflags | /test_suite/tests/bitflag_tests.rs | UTF-8 | 2,185 | 3.046875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | extern crate enumflags;
#[macro_use]
extern crate enumflags_derive;
#[derive(EnumFlags, Copy, Clone, Debug)]
#[repr(u8)]
enum Test {
A = 1 << 0,
B = 1 << 1,
C = 1 << 2,
D = 1 << 3,
}
#[derive(EnumFlags, Copy, Clone, Debug)]
#[repr(u8)]
enum Test1 {
A = 1 << 0,
B = 1 << 1,
C = 1 << 2,
D ... | true |
d093c0374a47e38785f4c7f4549559fa22bc8717 | Rust | umartaufiqul/kecc-public | /src/ir/dtype.rs | UTF-8 | 47,166 | 2.90625 | 3 | [] | no_license | use core::convert::TryFrom;
use core::fmt;
use core::ops::Deref;
use failure::Fail;
use lang_c::ast;
use lang_c::span::Node;
use std::collections::{HashMap, HashSet};
use std::hash::Hash;
use itertools::izip;
use crate::ir::*;
use crate::some_or;
#[derive(Debug, PartialEq, Fail)]
pub enum DtypeError {
/// For un... | true |
0f0a22bf87eac8b0ef1156c9037bed0f410796d7 | Rust | hodasemi/Context | /vulkan-rs/src/commandpool.rs | UTF-8 | 2,988 | 2.5625 | 3 | [] | no_license | use utilities::prelude::*;
use crate::impl_vk_handle;
use crate::prelude::*;
use std::sync::Arc;
pub struct CommandPoolBuilder {
flags: VkCommandPoolCreateFlagBits,
queue_family_index: u32,
}
impl CommandPoolBuilder {
pub fn set_flags(mut self, flags: impl Into<VkCommandPoolCreateFlagBits>) -> Self {
... | true |
30e91e99534172d15369693a79384bb4f5791be1 | Rust | FroVolod/cli_dialoguer_strum_2 | /src/command/on_off_line_mode/server/sender/receiver/transaction_actions/delete_access_key_type/mod.rs | UTF-8 | 3,488 | 2.703125 | 3 | [] | no_license | use structopt::StructOpt;
use std::str::FromStr;
use dialoguer::{
Input,
};
use async_recursion::async_recursion;
use super::super::{
ActionSubcommand,
CliActionSkipSubcommand
};
#[derive(Debug)]
pub struct DeleteAccessKeyAction {
pub public_key: String,
pub next_action: Box<ActionSubcommand>
}
... | true |
c111ca046a92016d13acfe48665dfe82f2557eda | Rust | stackcats/leetcode | /algorithms/easy/longest_harmonious_subsequence.rs | UTF-8 | 582 | 2.796875 | 3 | [
"MIT"
] | permissive | // https://leetcode.com/problems/longest-harmonious-subsequence/
use std::collections::HashMap;
impl Solution {
pub fn find_lhs(nums: Vec<i32>) -> i32 {
let mut dt = HashMap::new();
let mut ans = 0;
for n in nums.iter() {
let ct = dt.entry(n).or_insert(0);
*ct += 1... | true |
37840843f50210e5909ea555f56d0d30033bcbbf | Rust | EFanZh/LeetCode | /src/problem_0229_majority_element_ii/boyer_moore_majority_vote.rs | UTF-8 | 1,699 | 3.15625 | 3 | [] | no_license | pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
impl Solution {
pub fn majority_element(nums: Vec<i32>) -> Vec<i32> {
let mut result_1 = 0;
let mut votes_1 = 0;
let mut result_2 = 0;
let m... | true |
0efc1d1b23251e3e961b6476f9fcc26a0434bfd8 | Rust | willbush/wump | /src/game.rs | UTF-8 | 8,004 | 2.625 | 3 | [
"MIT"
] | permissive | #[cfg(test)]
#[path = "./game_test.rs"]
pub mod game_test;
use std::fmt;
use std::rc::Rc;
use bat::SuperBat;
use map::{gen_rand_valid_path_from, is_adj, RoomNum};
use message::Message;
use pit::BottomlessPit;
use player::{Action, Player};
use util::*;
use wumpus::Wumpus;
pub const MAX_TRAVERSABLE: usize = 5;
pub tr... | true |
999cbc5b3cd0af47d992d62ce15f762900c939b3 | Rust | SaiKrishna1908/newhistory | /src/lib.rs | UTF-8 | 572 | 2.90625 | 3 | [] | no_license | pub use std::env;
pub use std::iter;
pub mod lib_history {
pub fn get_history(file_name: String) -> Vec<String> {
let history_file = file_name;
let history_dump =
match std::fs::read_to_string(history_file) {
Ok(f) => f,
Err(_e) => panic!("C... | true |
6899849d8f38b47c033eec9a42fae81d7d9b7711 | Rust | gnoliyil/fuchsia | /third_party/rust_crates/forks/hound/src/write.rs | UTF-8 | 35,752 | 2.671875 | 3 | [
"BSD-2-Clause",
"Apache-2.0",
"GPL-1.0-or-later",
"LicenseRef-scancode-free-unknown",
"GPL-2.0-only"
] | permissive | // Hound -- A wav encoding and decoding library in Rust
// Copyright (C) 2015 Ruud van Asseldonk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// A copy of the License has been included in the root of the repository.
// Unless r... | true |
f700e891f2a92e55173c038306af65a288b59e71 | Rust | nao-kobayashi/PrjEuler | /problem70/src/main.rs | UTF-8 | 1,698 | 3.5625 | 4 | [] | no_license | fn main() {
let mut smaller_n = 999999999_u32;
let mut smaller: f64 = 999999999999.0;
let mut primes = Vec::new();
for n in 2..30000 {
if is_prime(n) {
primes.push(n);
}
}
for (i, p1) in primes.iter().enumerate() {
for index in (i + 1)..primes.len() {
... | true |
f61fde9a9a3d6f3bffc9f75ab24fc54c2be81708 | Rust | nmaraston/reproto | /lib/backend/src/dynamic_decode.rs | UTF-8 | 3,980 | 2.625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! # Helper trait for building a dynamic-language decode method
use base_decode::BaseDecode;
use converter::Converter;
use core::{Loc, RpInterfaceBody, RpType, WithPos};
use core::errors::*;
use dynamic_converter::DynamicConverter;
use genco::Tokens;
pub trait DynamicDecode<'el>
where
Self: Converter<'el>,
S... | true |
debab9b274a126fa2f48e19c8ba1a7a36b9e1eb3 | Rust | omerbenamram/AOC2019 | /day11/src/lib.rs | UTF-8 | 3,703 | 3.296875 | 3 | [] | no_license | #![deny(unused_must_use)]
use anyhow::Error;
use anyhow::{bail, Context, Result};
use intcode_computer::{ExecutionStatus, IntcodeComputer};
use log::debug;
use std::collections::HashMap;
use std::convert::TryFrom;
#[derive(Debug, Clone, Copy)]
enum Direction {
Up,
Down,
Left,
Right,
}
#[derive(Debug,... | true |
5444322d7ec1bb625379c7ed3075b3ff6bf692f9 | Rust | DutchGhost/Advent-Of-Code-2019 | /Rust/day12/src/main.rs | UTF-8 | 5,059 | 2.953125 | 3 | [] | no_license | static PUZZLE: &'static str = include_str!(r"..\..\..\Inputs\day12.txt");
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
struct Vec3 {
x: isize,
y: isize,
z: isize,
}
#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash)]
struct Moon {
location: Vec3,
velocity: Vec3,
}
impl Moon {
fn kinetic_... | true |
994259e024dcc0e01873ff4f698f6df58befc67c | Rust | Kreedzt/Learn-Tao-Of-Rust | /3.类型系统/3.6.trait-limit/src/main.rs | UTF-8 | 1,956 | 3.546875 | 4 | [] | no_license | // feature 必须放在文件顶部
#![feature(specialization, generic_associated_types)]
use std::ops::Add;
// 本地类型 Int
#[derive(PartialEq)]
struct Int(i32);
// Add trait 是标准库中的, 所以不违反孤儿规则
impl Add<i32> for Int {
type Output = i32;
fn add(self, other: i32) -> Self::Output {
(self.0) + other
}
}
// Option<T> 会将... | true |
1bcf145209f1ca1037c062cbe8960f90b9a3b348 | Rust | Azure/azure-sdk-for-rust | /services/autorust/codegen/src/lib_rs.rs | UTF-8 | 1,764 | 2.625 | 3 | [
"LicenseRef-scancode-generic-cla",
"MIT",
"LGPL-2.1-or-later"
] | permissive | use crate::{config_parser::Tag, identifier::parse_ident, write_file};
use crate::{ErrorKind, Result, ResultExt};
use camino::Utf8Path;
use proc_macro2::{Ident, TokenStream};
use quote::{quote, ToTokens};
pub fn create(tags: &[&Tag], path: &Utf8Path, print_writing_file: bool) -> Result<()> {
write_file(path, &creat... | true |
4be4258f16c4435ef19accb5c3e00dd78d915618 | Rust | jingfee/advent-of-code-rust | /src/y2015/day07.rs | UTF-8 | 7,513 | 3.21875 | 3 | [] | no_license | use crate::solver::Solver;
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
enum Operation {
AND(String, String),
OR(String, String),
LSHIFT(String, u8),
RSHIFT(String, u8),
NOT(String),
ASSIGN(u16),
ASSIGNREF(String),
}
pub struct Instruct... | true |
6ccacf70a7f5d78697a5f73c6150528cc04a0c82 | Rust | isabella232/sxg-rs | /sxg_rs/src/http_parser/base.rs | UTF-8 | 3,582 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | true |
a259145e59507ff7cf2ad43f162593afbb669d95 | Rust | crazcalm/epl-book | /src/chapter_2_3.rs | UTF-8 | 2,517 | 4.03125 | 4 | [
"MIT"
] | permissive | pub trait NodeBasicMovement<T> {
fn move_to_left(&mut self);
fn move_to_right(&mut self);
fn insert_to_left(&mut self, item: T);
fn insert_to_right(&mut self, item: T);
}
#[derive(Debug)]
pub struct NodeInSequence<T> {
pub current_node: T,
pub left_list: Vec<T>,
pub right_list: Vec<T>,
}
i... | true |
d230eae63a455acc08bcd12c75f2a6af092c180a | Rust | niofis/light | /light/src/ilios/point.rs | UTF-8 | 3,187 | 3.40625 | 3 | [] | no_license | use super::float::Float;
use crate::ilios::generic_vector::GVector4;
use crate::ilios::vector::Vector;
use std::ops;
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Point(pub Float, pub Float, pub Float); //x,y,z
impl From<GVector4> for Point {
fn from(gv: GVector4) -> Self {
Point(gv.0, gv.1, gv.2)
... | true |
9e9dceb5d9309d89d6889f0d3c044e0f4039faa7 | Rust | photon-garden/recreating-sainte-victoire-en-rond | /snapshots/2021-10-29 00:24:21/extensions/line_segment.rs | UTF-8 | 479 | 2.75 | 3 | [] | no_license | use crate::prelude::*;
pub type LineSegment = [Point2; 2];
pub trait LineSegmentExtension {
fn length2(&self) -> f32;
fn interpolate(&self, progress: NormalizedF32) -> Point2;
}
impl LineSegmentExtension for LineSegment {
fn length2(&self) -> f32 {
self[0].distance2(self[1])
}
fn interpol... | true |
e9aa1b3cd295cb481ded3ac601b015efa6f0680f | Rust | kerryeon/smartx-whitedog | /zeus/core/src/models/dp.rs | UTF-8 | 2,451 | 3 | 3 | [
"MIT"
] | permissive | /// 직접구매조회
pub mod get {
use smartx_whitedog_common::models::chrono::DateTime;
/// 직접구매조회
#[cfg_attr(feature = "rocket2", derive(rocket::FromForm))]
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct Request {
/// 시작일자
pub date_begin: Option<DateTime>,
/// 종... | true |
30a0e2e29a3f01bbc3c4c630782e5924900f3a5d | Rust | DnailZ/os-tutorial-summer-of-code | /leetcode/src/sol13.rs | UTF-8 | 476 | 3.375 | 3 | [] | no_license | struct Solution;
impl Solution {
pub fn is_valid(s: String) -> bool {
let mut v = vec![];
for x in s.chars() {
match x {
'('| '[' | '{' => v.push(x),
')' => if v.pop() != Some('(') { return false; },
']' => if v.pop() != Some('[') { return... | true |
c934ec29969cc124d978a6372cbd2283460223e1 | Rust | Eolien55/Voila | /voila/src/error.rs | UTF-8 | 3,977 | 2.890625 | 3 | [
"MIT"
] | permissive | use ansi_term::{Colour::*, Style};
use std::error::Error;
use std::fmt;
use std::ops::Range;
/// Error that is ready to represent to the user in a nice way,
/// including a line snippet with the error position, and a bunch
/// of contexts to help the user know what the program was up to
/// when the error happened.
#[... | true |
72567f3e26466b07ef01a27cf0a3c65acb879f9f | Rust | ramosbugs/datatest | /src/data.rs | UTF-8 | 3,871 | 2.8125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! Support module for `#[datatest::data(..)]`
use serde::de::DeserializeOwned;
use std::boxed::FnBox;
use test::TDynBenchFn;
use yaml_rust::parser::Event;
use yaml_rust::scanner::Marker;
/// Descriptor used internally for `#[datatest::data(..)]` tests.
#[doc(hidden)]
pub struct DataTestDesc {
pub name: &'static s... | true |
0fea45fa3367ff74d88ac25f2a10b4279f9d11f7 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/quote/src/to_tokens.rs | UTF-8 | 5,149 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use
super
:
:
TokenStreamExt
;
use
core
:
:
iter
;
use
proc_macro2
:
:
{
Group
Ident
Literal
Punct
Span
TokenStream
TokenTree
}
;
use
std
:
:
borrow
:
:
Cow
;
use
std
:
:
rc
:
:
Rc
;
/
/
/
Types
that
can
be
interpolated
inside
a
quote
!
invocation
.
/
/
/
/
/
/
[
quote
!
]
:
macro
.
quote
.
html
pub
trait
ToTokens
{
/
... | true |
505c8ce2b73b92e52e851f0e5360b6a220c30bc4 | Rust | acdibble/aoc | /2016/rs/day08/src/main.rs | UTF-8 | 3,763 | 3.46875 | 3 | [] | no_license | use std::env;
use std::fs;
use std::path::Path;
use std::time::SystemTime;
struct Screen([[char; 50]; 6]);
#[derive(Debug)]
enum RotationType {
Row,
Column,
}
#[derive(Debug)]
enum Command {
Rect(usize, usize),
Rotate(RotationType, usize, usize),
}
impl Screen {
fn new() -> Self {
Self([... | true |
76fc9b4d7b31df856645db6ad608d5db92eca7d3 | Rust | aeleos/oldandboring | /kernel/src/boot/mod.rs | UTF-8 | 9,335 | 3.109375 | 3 | [] | no_license | //! Provides information about the initial status of the system.
mod multiboot2;
mod multiboot;
#[cfg(target_arch = "x86_64")]
use arch::vga_buffer;
use memory::{get_kernel_end_address, get_kernel_start_address, FreeMemoryArea, PhysicalAddress,
PAGE_SIZE};
/// Lists possiblities for boot sources.
enum Bo... | true |
a8a1de01b0144acfab1d883f0b0eecb6b426ec1b | Rust | kitsuneninetails/config-rust | /src/value.rs | UTF-8 | 17,365 | 3.53125 | 4 | [] | no_license | use std::collections::HashMap;
use std::fmt::{Display, Formatter, Result as FmtResult};
use std::fmt;
use error::*;
use serde::de::{Deserialize, Deserializer, Visitor};
use config::Config;
/// Underlying kind of the configuration value.
#[derive(Debug, Clone)]
pub enum ValueKind {
Nil,
Boolean(bool),
Inte... | true |
4bbae5f69558dd454d9c2bba985cc89704785a3e | Rust | lenscas/silver_surf | /src/lib.rs | UTF-8 | 1,214 | 2.78125 | 3 | [] | no_license | #[cfg(test)]
mod tests {
#[test]
fn it_works() {
use crate::{call, Config, Method};
let _t = call::<()>(Config {
url: "http://httpbin.org/get".into(),
method: Method::Get,
body: None,
headers: None,
});
}
}
pub enum Method {
Post,
... | true |
f5e9ac8f04f0226bde2c39a206d162fd90a7c463 | Rust | DelSkayn/toyjs | /crates/parser/src/stmt.rs | UTF-8 | 29,497 | 2.75 | 3 | [] | no_license | use super::{Allocator, Error, ErrorKind, Parser, Result};
use ast::{
symbol_table::{DeclType, ScopeKind},
Binding, BindingRestElement, Expr, Literal,
};
use token::{t, TokenKind};
impl<'a, 'b, A: Allocator + Clone> Parser<'a, 'b, A> {
pub(crate) fn parse_stmt(&mut self) -> Result<ast::Stmt<A>> {
le... | true |
efcb4f4015de76dd14913ca0f93dbc2157de6cfd | Rust | Silentdoer/RustTetris | /tetris/src/model/mod.rs | UTF-8 | 1,438 | 2.546875 | 3 | [] | no_license | // 这里不要pub,然后再后面用pub use进行re-export,就能令外部只能model::CanvasPiece而不能model::canvas_piece::CanvasPiece
mod canvas_pixel;
mod canvas;
mod canvas_piece;
mod coordinate;
pub use canvas_pixel::CanvasPixel;
pub use canvas::Canvas;
pub use canvas_piece::{CanvasPiece, PieceType, PieceDirection};
pub use coordinate::Coordinate;
us... | true |
3e9d63eff9d6c42939a3004f7aabb44f7d159369 | Rust | Raeltik/DGTProject1 | /src/main.rs | UTF-8 | 2,918 | 3.046875 | 3 | [] | no_license | use std::net::TcpListener;
use std::net::TcpStream;
use std::io::prelude::*;
//use regex::Regex;
//use serde_json::{Value, Error};
//extern crate regex;
extern crate serde;
extern crate serde_json;
//use std::io::Write;
#[macro_use]
extern crate serde_derive;
use serde_json::{Value, Error};
#[derive(Deserialize, ... | true |
3183dc10936ad4ea7ec8f0753a00bbaeb20057bb | Rust | semrov/Advent-of-code-2017 | /src/day10/test.rs | UTF-8 | 755 | 2.921875 | 3 | [] | no_license | use super::KnotHash;
#[test]
fn test_hash() {
let mut knot_hash = KnotHash::new(5);
knot_hash.hash(&"3,4,1,5".split(",").map(|x| x.parse().unwrap()).collect());
assert_eq!(knot_hash.list,vec![3,4,2,1,0]);
}
#[test]
fn test_hash_code()
{
let mut knot_hash = KnotHash::new_full();
let v = knot_hash.... | true |
1014bbba80a405a6047b719aef1ea2bcb268dc8e | Rust | akhilkpdasan/rs-attendance | /src/db_executor.rs | UTF-8 | 3,120 | 2.59375 | 3 | [
"MIT"
] | permissive | use actix::prelude::*;
use db::*;
use diesel::prelude::*;
use error::MyError;
use models::{NewUser, Student};
use r2d2::Pool;
use r2d2_diesel::ConnectionManager;
pub struct DbExecutor {
pub pool: Pool<ConnectionManager<PgConnection>>,
}
impl Actor for DbExecutor {
type Context = SyncContext<Self>;
}
pub stru... | true |
096da0ac06da0d23ca061a16b1c3bf605ee1b635 | Rust | moritzbeck/vcdim | /examples/visibility_structure.rs | UTF-8 | 4,578 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | extern crate vcdim;
use vcdim::*;
use std::fs;
use std::collections::HashMap;
macro_rules! println_ignore_err {
($fmt:expr, $($arg:tt)*) => (
use std::io::Write;
match write!(&mut std::io::stdout(), concat!($fmt, "\n"), $($arg)*) {
Ok(_) => {},
Err(e) => {
i... | true |
d8a272d181ca555911734183ce79bc0bc2598e0f | Rust | bddap/encstream | /src/crypt.rs | UTF-8 | 1,311 | 2.65625 | 3 | [] | no_license | //! decrypt and encrypt messages from and to AsyncRead and AsyncWrite streams
use crate::fragment::{read_noise, write_noise};
use either::Either;
use futures::{AsyncRead, AsyncWrite};
use snow::{error::SnowError, Session};
use std::io;
use std::sync::Mutex;
pub async fn encrypt_write<'a, W: AsyncWrite + Unpin>(
w... | true |
283340913022a9967f5f041e2cf398e34f838916 | Rust | jmmk/rustcap | /pcap-sys/build.rs | UTF-8 | 3,503 | 2.515625 | 3 | [
"MIT"
] | permissive | #[cfg(unix)]
extern crate pkg_config;
#[cfg(all(unix, feature = "static-libpcap"))]
extern crate cmake;
#[cfg(windows)]
use std::path::PathBuf;
#[cfg(all(unix, not(feature = "static-libpcap")))]
use std::process::Command;
#[cfg(windows)]
fn main() {
let dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let... | true |
e10b5ea9ea4a1f26f98775c0f7e78d5fb3c6d1b8 | Rust | mrksrtrs/NES_Emulator | /src/bus.rs | UTF-8 | 428 | 3.078125 | 3 | [] | no_license | const RAM_SIZE: usize = 64 * 1024;
pub struct Bus {
// Fake ram (TODO: change for real ram later)
pub ram: [u8; RAM_SIZE]
}
impl Bus {
pub fn new() -> Self {
Self {
ram: [0x00; RAM_SIZE]
}
}
pub fn write(&mut self, addr: u16, data: u8) {
self.ram[addr as usize... | true |
1575e066a3a79cdda82fc76278c53de8f6d2545f | Rust | thomas9911/imgopt_python | /src/lib.rs | UTF-8 | 2,392 | 2.8125 | 3 | [] | no_license | const HELP_TEXT: &'static str = r#"
Python library to convert/optimize images.
Uses Rust glue to communicate with the mozjpeg, pngquant, webp and svgcleaner.
"#;
use imgopt_native::Format;
use pyo3::exceptions::{PyRuntimeError, PyValueError};
use pyo3::prelude::*;
const JPEG: &'static str = "JPEG";
const PNG: &'stat... | true |
b964851b08815aabb8e9c374239f6f9cc6e98db6 | Rust | AllanDuee/workstation | /site/src/forms/create_user.rs | UTF-8 | 747 | 3.046875 | 3 | [] | no_license | use rocket::response::Redirect;
use rocket::request::Form;
#[derive(FromForm)]
pub struct TakeUser {
firstname: String,
lastname: String,
password: String,
repassword: String
}
#[post("/take_user", data = "<form>")]
pub fn take_user(form: Form<TakeUser>) -> Result<Redirect, String> {
if form.first... | true |
961ccb228956f8ac1b7b5d35442309347c4aa1f0 | Rust | Atmelfan/scpi-rs | /scpi/src/parser/expression/numeric_list.rs | UTF-8 | 4,123 | 3.921875 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! # 8.3.3 Numeric Lists
//!
//! A numeric list is a an expression format for compactly expressing numbers and ranges of
//! numbers in a single parameter.
use crate::error::{Error, ErrorCode};
type Number<'a> = crate::parser::tokenizer::Token<'a>;
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum Token<'a> {
Num... | true |
347a267adda1d9825112f589564c7547c47f2b9c | Rust | Emm/rust-ledger-parser | /src/model_internal.rs | UTF-8 | 1,699 | 3.21875 | 3 | [
"Unlicense"
] | permissive | use model::*;
pub enum LedgerItem {
EmptyLine,
LineComment(String),
Transaction(Transaction),
CommodityPrice(CommodityPrice),
}
pub fn convert_items_to_ledger(items: Vec<LedgerItem>) -> Ledger {
let mut transactions = Vec::<Transaction>::new();
let mut commodity_prices = Vec::<CommodityPrice>:... | true |
c5c1d7451c4e0f89a8318330586f57ce1210b8a2 | Rust | zenito9970/Patra | /src/config.rs | UTF-8 | 1,868 | 2.59375 | 3 | [] | no_license | use crate::cli;
use serde_derive::Deserialize;
use std::fs;
use std::io::{BufReader, Read};
use toml;
#[derive(Deserialize)]
pub struct Config {
pub command: Option<String>,
pub input_dir: Option<String>,
pub output_dir: Option<String>,
pub logfile: Option<String>,
pub threads: Option<usize>,
}
pu... | true |
3780893e8437653cb8dc016226e08d81332e0eaf | Rust | jfredett/os | /src/vga/color_code.rs | UTF-8 | 580 | 3.328125 | 3 | [] | no_license | use super::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(transparent)]
pub struct ColorCode(u8);
impl ColorCode {
pub fn new(foreground: Color, background: Color) -> ColorCode {
ColorCode((background as u8) << 4 | (foreground as u8))
}
}
#[cfg(test)]
mod test {
use crate::*;
use supe... | true |
915c664d363e4f07854c68bc375cadf365caabdd | Rust | rollniak/acmed | /acmed/src/template.rs | UTF-8 | 1,934 | 3.234375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"FSFAP"
] | permissive | use acme_common::error::Error;
use serde::Serialize;
use serde_json::Value;
use tinytemplate::TinyTemplate;
macro_rules! default_format {
($value: ident, $output: ident) => {{
$output.push_str(&$value.to_string());
Ok(())
}};
}
fn formatter_rev_labels(value: &Value, output: &mut String) -> tin... | true |
eef78ae08595abf7d586e5fa1d39220675845f88 | Rust | spec-tacles/spectacles | /brokers/redis/src/config.rs | UTF-8 | 1,334 | 2.625 | 3 | [] | no_license | use anyhow::Result;
use clap::Parser;
use config;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize, Parser)]
#[command(name = "spectacles-redis")]
pub struct Config {
#[arg(long, short, env = "REDIS_CONFIG_FILE", exclusive = true)]
pub config_file: Option<String>,
#[arg(long, short, env ... | true |
ee583bd96f8649748fed9e448d6e87ba754c91e0 | Rust | mongodb/mongo-rust-driver | /src/runtime/http.rs | UTF-8 | 2,449 | 3.171875 | 3 | [
"OpenSSL",
"Apache-2.0"
] | permissive | // Suppress noisy warnings when a method is not used under a certain feature flag.
#![allow(unused)]
use reqwest::{IntoUrl, Method, Response};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use crate::error::{Error, Result};
#[derive(Clone, Debug, Default)]
pub(crate) struct HttpClient {
inner: reqwe... | true |
ef54aa198028797561a65e2a4c28723d305eeafd | Rust | oknozor/tp_3_modelisation_par_agent | /racman_app/src/main.rs | UTF-8 | 3,690 | 2.515625 | 3 | [] | no_license | #[macro_use]
extern crate lazy_static;
extern crate serde;
#[macro_use]
extern crate serde_derive;
use std::fs::File;
use std::io::prelude::*;
use nannou::event::Key;
use nannou::prelude::*;
use racman_lib::core::coordinate::Coord;
use racman_lib::core::sma::Sma;
use racman_lib::RgbColor;
mod user_config;
lazy_sta... | true |
c78c39ffc3e6ad1702897f5ce4735a387dc3ffe5 | Rust | SuperFluffy/telamon | /telamon-gen/src/ast/choice/mod.rs | UTF-8 | 764 | 2.765625 | 3 | [] | no_license | pub mod enumeration;
pub mod integer;
pub use super::*;
pub use self::enumeration::EnumDef;
pub use self::integer::IntegerDef;
#[derive(Clone, Debug, PartialEq)]
pub enum ChoiceDef {
CounterDef(CounterDef),
EnumDef(EnumDef),
IntegerDef(IntegerDef),
}
impl ChoiceDef {
pub fn type_check(&self) -> Resul... | true |
c2c76ab41df1d38041ceeea81f4d88409171e4ae | Rust | AnthonyMl/AoC2019 | /09/sensor_boost/src/main.rs | UTF-8 | 5,142 | 2.96875 | 3 | [] | no_license | use std::{collections::HashMap, io::{stdin}};
use num_derive::{FromPrimitive, ToPrimitive};
use num_traits::{FromPrimitive, ToPrimitive, Zero};
use num_bigint::{BigInt};
mod data;
#[derive(FromPrimitive, ToPrimitive, Debug)]
enum ParameterMode {
Position = 0,
Immediate = 1,
Relative = 2,
}
use ParameterMode::*;... | true |
78beadbdacd6b775afcfe68eb1d88b9127515584 | Rust | roppa/learning-rust | /game-of-life/src/main.rs | UTF-8 | 1,309 | 2.875 | 3 | [] | no_license | use std::{thread, time};
mod game;
fn main() {
let one_second = time::Duration::from_millis(1000);
let mut cells = vec![false; 1600];
cells[1] = true;
cells[2] = true;
cells[6] = true;
cells[30] = true;
cells[31] = true;
cells[26] = true;
cells[51] = true;
cells[52] = true;
... | true |
2ed88d54937241149f5c3813a22818f42733a539 | Rust | justinmimbs/rs-wordsearch | /src/main.rs | UTF-8 | 705 | 2.953125 | 3 | [] | no_license | mod dictionary;
use std::env;
use std::process;
use wordsearch::{Board, Dict};
fn main() {
let args = env::args();
let board_str = args.skip(1).next().unwrap_or_else(|| {
eprintln!("Argument error: missing argument");
process::exit(1);
});
let board: Board = match board_str.parse() {... | true |
9b8a30053980e53f9d6abdfbac098d1356b6fe57 | Rust | hiking90/rushell_deps_linefeed | /src/terminal.rs | UTF-8 | 10,077 | 3.25 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Provides a low-level terminal interface
use std::io;
use std::time::Duration;
use mortal::{self, PrepareConfig, PrepareState, TerminalReadGuard, TerminalWriteGuard};
use crate::sys;
pub use mortal::{CursorMode, Signal, SignalSet, Size};
/// Default `Terminal` interface
pub struct DefaultTerminal(mortal::Termina... | true |
9f23c819286ae68bd83bb7551f82c72b606f50ba | Rust | quells/cryptopals-rs | /src/score.rs | UTF-8 | 2,297 | 3.421875 | 3 | [] | no_license | pub trait Scorer {
fn score(&self, c: char) -> usize;
fn score_message(&self, msg: &str) -> usize {
msg.chars()
.map(|c| self.score(c))
.fold(0, |acc, x| acc + x)
}
fn best_guess<K, F, E>(&self, bytes: &[u8], keys: &Vec<K>, transform: F) -> (K, String)
where K: Copy... | true |
935acc9250999d4c5be98f70ad31e96118e23974 | Rust | Skelebot/tanks | /src/physics/systems.rs | UTF-8 | 1,435 | 2.671875 | 3 | [] | no_license | use amethyst::{
core::Transform,
ecs::{
System, Join,
ReadStorage, WriteStorage, WriteExpect, ReadExpect
}
};
use crate::physics::{Physics, Body};
pub struct StepperSystem;
impl<'s> System<'s> for StepperSystem {
type SystemData = (
WriteExpect<'s, Physics>,
);
fn... | true |
bc740c83f842f31b8a1207e9a0bbbf56e2225409 | Rust | Sk3pz/mini_mmo_client | /src/network/event_io.rs | UTF-8 | 3,157 | 2.765625 | 3 | [] | no_license | use std::net::TcpStream;
use crate::packet_capnp::event;
use capnp::message::{TypedReader, Builder, HeapAllocator};
use capnp::serialize;
use crate::utils::systime;
use crate::network::message::Message;
/// Sends a message event
pub fn write_event_message<S: Into<String>>(mut stream: &TcpStream, msg_str: S, data: S) -... | true |
f44ab65c1b11a82e34f2fa7567fff8a515248613 | Rust | xldenis/flowistry | /src/core/analysis.rs | UTF-8 | 4,059 | 2.578125 | 3 | [] | no_license | use anyhow::Result;
use log::debug;
use rustc_hir::{
intravisit::{self, NestedVisitorMap, Visitor},
itemlikevisit::ItemLikeVisitor,
BodyId, ForeignItem, ImplItem, Item, TraitItem,
};
use rustc_middle::{hir::map::Map, ty::TyCtxt};
use rustc_span::Span;
use std::time::Instant;
pub trait FlowistryOutput: Send + Syn... | true |
800036c96ddba9dc1cd68a090705874fb967fb87 | Rust | archer884/unit-rs | /src/lib.rs | UTF-8 | 5,214 | 3.5625 | 4 | [
"Unlicense"
] | permissive | use std::ops::{ Mul, Div };
pub trait Unit: Sized {
type Data: Mul<Output=Self::Data> + Div<Output=Self::Data>;
type Base: Unit<Data=Self::Data, Base=Self::Base>;
fn factor() -> Self::Data;
fn value(&self) -> Self::Data;
fn new(data: Self::Data) -> Self;
fn to<T>(self) -> T where
T: U... | true |
8879a55f5498f7fb5f880dbf31bf3397bb6b5547 | Rust | Keksoj/suivre_le_rust_book | /06_Enums/match_syntaxe/src/main.rs | UTF-8 | 2,177 | 3.625 | 4 | [] | no_license | // 2019-01-08
// match permet d'exécuter tel ou tel code en fonction de la correspondance de
// certain pattern. S'ils correspondent, s'ils matchent, on éxécute tel code.
// Sinon, on éxécute tel autre. Les patterns conditions sont multiples.
// Imaginons une application de match qui trie des pièces dans un distri... | true |
9639a3a9692e524a39686f8cd6445bc11cbf1767 | Rust | isgasho/parsercher | /src/dom/text.rs | UTF-8 | 969 | 4.34375 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | //! Module of Text structure.
/// A structure that expresses something other than tags and comments.
#[derive(Debug, PartialEq, Clone)]
pub struct Text {
text: String,
}
impl Text {
/// Create new Text structure.
///
/// # Arguments
/// * `text` - If `<h1>section</h1>`, then `section`.
pub fn ... | true |
b8de9fbd86d8956c6d2661c324ccbd3a08ad9a66 | Rust | Xiphoseer/prosemirror-rs | /src/util.rs | UTF-8 | 1,118 | 4.15625 | 4 | [] | no_license | //! # Generic utilities
/// A type the holds a value of A or B or both.
pub enum EitherOrBoth<A, B> {
/// Both values
Both(A, B),
/// Just a value of type A
Left(A),
/// Just a value of type B
Right(B),
}
impl<A, B> EitherOrBoth<A, B> {
/// Get the left value if present
pub fn left(&se... | true |
f33b29b3e00cce07e5267fb64e9d43c7c4c74290 | Rust | zither/nickel-mysql | /examples/example.rs | UTF-8 | 1,085 | 2.75 | 3 | [
"MIT"
] | permissive | #[macro_use] extern crate nickel;
extern crate mysql;
extern crate nickel_mysql;
use nickel::{Nickel, HttpRouter};
use mysql::value::from_value;
use nickel_mysql::{MysqlMiddleware, MysqlRequestExtensions};
struct User {
id: u32,
email: String,
}
fn main() {
let mut app = Nickel::new();
app.utilize(... | true |
558ebda1b0ddcadb0e4d57dafcf53c31bf8166d9 | Rust | FajarAdnan/Programming-Languages-homework | /hw4/src/main.rs | UTF-8 | 947 | 3.984375 | 4 | [] | no_license | // use std::io;
fn main() {
/*
let mut x = String::new();
io::stdin().read_line(&mut x).expect("Error reading input");
println!("You selected: {}", x);
let y = x.as_str();
let value = value_in_cents(Coin::y);
println!("The value of a {} is {}.", y, value);
*/
//***Tried to get user... | true |
9af436a84f62522c7104ea04ef77b9f088b3bc3c | Rust | AllenDuke/azeroth-vm | /src/mem/mod.rs | UTF-8 | 3,386 | 2.59375 | 3 | [] | no_license | use std::borrow::Borrow;
use std::hash::{Hash, Hasher};
use crate::bytecode::class::Class;
use crate::classpath::Classpath;
use chashmap::CHashMap;
use regex::Regex;
pub mod heap;
pub mod metaspace;
pub mod klass;
pub mod stack;
pub mod strings;
// pub const PTR_SIZE: usize = std::mem::size_of::<usize>();
// 32-bi... | true |
e43d658f90312cf66d0e86f3e83c890ee8bc93a7 | Rust | WorryingWonton/rust-bat | /src/stringYak.rs | UTF-8 | 588 | 3.25 | 3 | [] | no_license | #[allow(non_snake_case)]
fn stringYak(s: String) -> String {
let mut new_s = String::from("");
let mut i = 0;
while i < s.len() {
if i+2 < s.len() && s.chars().nth(i).unwrap() == 'y' && s.chars().nth(i+2).unwrap() == 'k' {
i += 3;
continue;
}
new_s.push(s.char... | true |
14c57c9f1e0c4775726d07ebd5bcb6c74215d01a | Rust | starfleetcadet75/rmips | /src/control/instructions.rs | UTF-8 | 39,215 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! This module contains the helper functions that are used by the `Cpu` for executing instructions.
use std::convert::TryFrom;
use crate::control::cpu::{Cpu, DelayState};
use crate::control::exception::Exception;
use crate::control::instruction::Instruction;
use crate::control::registers::{Cp0Register, Register};
use... | true |
2db04de90a2d25380a127fdc2f61b5064156f481 | Rust | agrif/moiety | /src/mhk/utility.rs | UTF-8 | 2,209 | 2.640625 | 3 | [] | no_license | use anyhow::Result;
use bincode::Options;
use smol::io::{AsyncRead, AsyncReadExt};
pub async fn deserialize_from<'a, R, T>(
reader: &'a mut R
) -> Result<T>
where
R: AsyncRead + Unpin,
T: serde::de::DeserializeOwned,
{
let size = std::mem::size_of::<T>();
let mut buf = vec![0u8; size];
reader.r... | true |
89187d28d21c79c855d262abca4ce592ee2c42ad | Rust | amhk/ash | /src/modinfo.rs | UTF-8 | 2,664 | 3.3125 | 3 | [
"MIT"
] | permissive | use lazy_static::lazy_static;
use regex::Regex;
use serde::Deserialize;
use serde_json;
use std::convert::TryFrom;
#[derive(Deserialize, Debug)]
pub struct ModuleInfo {
pub module_name: String,
pub path: Vec<String>,
pub installed: Vec<String>,
}
impl TryFrom<&str> for ModuleInfo {
type Error = serde_... | true |
98122f494c760442ecc1ac38699de70a0c118ea3 | Rust | lo48576/opaque_typedef | /opaque_typedef_tests/tests/int32.rs | UTF-8 | 14,135 | 3.015625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Tests for `int32` types.
extern crate opaque_typedef;
extern crate opaque_typedef_tests;
use opaque_typedef_tests::int32::Int32;
mod basic {
use super::*;
#[test]
fn ok() {
let v = Int32::from(42);
assert_eq!(v.to_i32(), 42);
}
}
mod cmp {
use super::*;
#[test]
fn p... | true |
d9a2bfcefe9ddc4733189b83d55dddc0d0e28382 | Rust | Frizi/norays | /src/math/point.rs | UTF-8 | 1,409 | 3.484375 | 3 | [] | no_license | use std::ops::{Add, AddAssign, Sub};
use math::{Float, Vector};
#[derive(PartialEq, Debug, Clone, Copy)]
pub struct Point<F: Float> {
pub x: F,
pub y: F,
pub z: F,
}
impl<F: Float> Point<F> {
pub fn new(x: F, y: F, z: F) -> Self {
Point { x, y, z }
}
pub fn origin() -> Self {
... | true |
16ace5b870bb0ec3a6bb327eff6e64afc8116f38 | Rust | uuhan/sonnerie | /src/database_reader.rs | UTF-8 | 5,051 | 3.1875 | 3 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | //! Read a database.
use std::path::{Path,PathBuf};
use std::fs::File;
use std::io::Seek;
use crate::merge::Merge;
use crate::record::OwnedRecord;
use crate::key_reader::*;
use crate::Wildcard;
use byteorder::ByteOrder;
/// Read a database in key-timestamp sorted format.
///
/// Open a database with [`new`](#method... | true |
17d434df7afbfe177915c486f8394aa9ebc1327c | Rust | kgv/rustapi | /src/um/memoryapi/virtual_alloc.rs | UTF-8 | 3,080 | 2.796875 | 3 | [] | no_license | use crate::{r#macro::FnOnce, shared::ntdef::Handle};
use anyhow::{ensure, Result};
use std::{io, ptr::NonNull};
use typed_builder::TypedBuilder;
/// Virtual allocation.
#[derive(FnOnce, TypedBuilder)]
pub struct VirtualAlloc {
#[builder(default)]
address: usize,
size: usize,
allocation_type: u32,
p... | true |
d3f153db2402c489a92dae1e6e8854980ed522f6 | Rust | Jason-Cooke/gluon | /check/src/substitution.rs | UTF-8 | 15,167 | 2.65625 | 3 | [
"MIT"
] | permissive | use std::{cell::RefCell, default::Default, fmt};
use union_find::{QuickFindUf, Union, UnionByRank, UnionFind, UnionResult};
use crate::base::{
fixed::{FixedVec, FixedVecMap},
kind::ArcKind,
symbol::Symbol,
types::{self, ArcType, Flags, FlagsVisitor, Skolem, Type, TypeContext, Walker},
};
use crate::ty... | true |
5b325b2e4e7dff02fa6971cb54fa1cc8c9a57d0f | Rust | numtide/treefmt | /src/eval_cache.rs | UTF-8 | 7,753 | 2.78125 | 3 | [
"MIT"
] | permissive | //! Keep track of evaluations
use crate::{
formatter::{Formatter, FormatterName},
get_path_meta, FileMeta,
};
use anyhow::Result;
use log::{debug, error, warn};
use serde::{Deserialize, Serialize};
use sha1::{Digest, Sha1};
use std::collections::BTreeMap;
use std::fs::{create_dir_all, read_to_string, File};
us... | true |
45db9fe3292c7c8e3c562c8192e1b082ea5ebd45 | Rust | boxdot/advent-of-code-2019 | /boxdot/src/day06.rs | UTF-8 | 2,985 | 3.53125 | 4 | [] | no_license | use std::collections::{HashSet, VecDeque};
type Error = Box<dyn std::error::Error>;
pub fn solve(input: &str) -> Result<(usize, usize), Error> {
let g = parse(input)?;
let part1 = g.num_orbits();
let part2 = g
.shortest_path_len(Vertex("YOU"), Vertex("SAN"))
.and_then(|len| len.checked_sub... | true |
2fd21a0314c91dad85e119b7b68363dc16c4787c | Rust | beqaabu/t3rn | /gateway/pallets/runtime-gateway/fixtures/weights/src/lib.rs | UTF-8 | 3,857 | 2.984375 | 3 | [
"Unlicense",
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | #![cfg_attr(not(feature = "std"), no_std)]
//! Transaction Weight Examples
pub use pallet::*;
#[frame_support::pallet]
mod pallet {
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
#[pallet::config]
pub trait Config: frame_system::Config {}
#[pallet::pallet]
pub str... | true |
254456d19b52df13fcc33c3ae1ef6429d4d08d54 | Rust | bitemyapp/my-limes | /src/common/mod.rs | UTF-8 | 5,564 | 2.53125 | 3 | [] | no_license | // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// since this is going to get included in examples that might not use everything, clear out warnings
// that are unne... | true |
ecdfc0a99570f94c1b58fff39c9778cd3df2eb91 | Rust | flier/tokio-kafka | /src/producer/config.rs | UTF-8 | 4,964 | 2.84375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::ops::{Deref, DerefMut};
use std::time::Duration;
use client::ClientConfig;
use compression::Compression;
use protocol::RequiredAcks;
/// The default amount of time the server will wait for acknowledgments
///
/// Defaults to 30 seconds, see
/// [`ProducerConfig::ack_timeout`](struct.ProducerConfig.html#ack_t... | true |
04761189dfecc406153e30826636a4d2d6163524 | Rust | VladCatalin19/Rust-MiniCAD | /src/shapes/canvas.rs | UTF-8 | 1,007 | 3.140625 | 3 | [
"MIT"
] | permissive |
use crate::shapes::shape::Shape;
use crate::shape_visitor::shape_visitor::ShapeVisitor;
use crate::utils::color::Color;
use std::error::Error;
pub struct Canvas {
height: u32,
width: u32,
color: Color
}
impl Canvas {
pub fn new(height: u32, width: u32, color: Color) -> Self {
return Canvas{h... | true |
a8d9269ce9ebcdeafac261e76f51a49cd4fd7bd6 | Rust | cubicvoid/billiards-rust | /src/billiards/base_edge.rs | UTF-8 | 3,738 | 3.265625 | 3 | [] | no_license | use std::ops::{Add, Sub, Neg, Mul, Div};
use rug::Rational;
use crate::vector::V2;
use crate::algebra::{Zero, One};
use crate::billiards::{Params, ParamsTrait};
use crate::billiards::singularity::{
BaseSingularity::{self, B0, B1}, BaseOrientation, BaseValues};
pub struct BaseEdge<'a, R>
where
R: ParamsTrait
{
... | true |
2ed403cf1f1b5bd77fae2894e3d1ae521f6530c4 | Rust | alesharik/smbios-lib | /src/structs/types/system_information.rs | UTF-8 | 12,879 | 2.90625 | 3 | [
"MIT"
] | permissive | use crate::{SMBiosStruct, UndefinedStruct};
use serde::{ser::SerializeStruct, Serialize, Serializer};
use core::{
array::TryFromSliceError,
convert::{TryFrom, TryInto},
fmt,
ops::Deref,
any
};
#[cfg(feature = "no_std")]
use alloc::{string::String, format};
/// # System Information (Type 1)
///
/// ... | true |
0b9e8ee6a9f2c2a0c943aae44b52dcd195d6360c | Rust | COLDTURNIP/raphanus_leetcode | /rust/src/p406.rs | UTF-8 | 3,930 | 3.703125 | 4 | [] | no_license | /*
Problem 406. Queue Reconstruction by Height
===========================================
https://leetcode.com/problems/queue-reconstruction-by-height/
You are given an array of people, people, which are the attributes of some people in a queue (not
necessarily in order). Each people[i] = [hi, ki] represents the ith... | true |
3f3e676c60291602a6ebb59c84bdee197cd9d9a7 | Rust | boa-dev/boa | /boa_parser/src/parser/statement/declaration/hoistable/mod.rs | UTF-8 | 9,768 | 2.6875 | 3 | [
"MIT",
"Unlicense"
] | permissive | //! Hoistable declaration parsing.
//!
//! More information:
//! - [ECMAScript specification][spec]
//!
//! [spec]: https://tc39.es/ecma262/#prod-HoistableDeclaration
#[cfg(test)]
mod tests;
mod async_function_decl;
mod async_generator_decl;
mod function_decl;
mod generator_decl;
pub(crate) mod class_decl;
use cra... | true |
3c74fc9e1e0579fd40603ebcd1c042ee38b1f386 | Rust | lazear/rosalind | /cons/src/main.rs | UTF-8 | 1,837 | 3.046875 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io::Write;
use utils::Fasta;
/// Transpose a matrix of An,m into a matrix of Am,n
fn transpose<T, I, V>(v: V) -> Vec<Vec<T>>
where
T: Copy,
I: AsRef<[T]>,
V: AsRef<[I]>,
{
let len = v.as_ref()[0].as_ref().len();
let mut outer = Vec::with_capacity(len);
for j in 0..le... | true |
400d0359568a77f07f0e0ada3b61720881d49169 | Rust | AtsukiTak/amqpr-api | /src/queue/bind.rs | UTF-8 | 1,076 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use amqpr_codec::{AmqpString, Frame, FrameHeader, FramePayload};
use amqpr_codec::method::MethodPayload;
use amqpr_codec::method::queue::{BindMethod, QueueClass};
use futures::sink::{Send, Sink};
use std::collections::HashMap;
pub type QueueBound<S> = Send<S>;
/// Bind a queue asynchronously.
/// That means we won'... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.