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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
fc2788621a5cf661683de2f96fe68d05703b474c | Rust | danielfrg/grpc-up-and-running | /ch3/server-stream/client/gen/ecommerce.rs | UTF-8 | 4,388 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | #[derive(Clone, PartialEq, ::prost::Message)]
pub struct Order {
#[prost(string, tag = "1")]
pub id: ::prost::alloc::string::String,
#[prost(string, repeated, tag = "2")]
pub items: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
#[prost(string, tag = "3")]
pub description: ::prost::al... | true |
4eb279eeb0c32dcfa35bfc093124505317d51138 | Rust | sam-wright/Advent-of-Code | /2018/day2/src/main.rs | UTF-8 | 2,195 | 3.359375 | 3 | [] | no_license | use std::collections::HashMap;
use std::fs::File;
use std::io::{self, Read};
fn main() -> io::Result<()> {
let mut file = File::open("input.txt")?;
//let mut file = File::open("test_input.txt")?;
//let mut file = File::open("test_input2.txt")?;
let mut contents = String::new();
file.read_to_string(... | true |
cf4b28b88c57c88902771a1ff2144f912a394874 | Rust | presciense/actix-mqtt | /src/error.rs | UTF-8 | 1,458 | 2.859375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use derive_more::Display;
use std::io;
/// Errors which can occur when attempting to handle mqtt connection.
#[derive(Debug)]
pub enum MqttError<E> {
/// Message handler service error
Service(E),
/// Mqtt parse error
Protocol(mqtt_codec::ParseError),
/// Unexpected packet
Unexpected(mqtt_codec:... | true |
1c466f5f057f7172a26339adbd65f43a766870c9 | Rust | rampion/advent-of-code | /2020/day/07/src/main.rs | UTF-8 | 4,401 | 3.25 | 3 | [] | no_license | use std::collections::HashMap;
use std::error;
type Error = Box<dyn error::Error>;
macro_rules! error {
($fmt:literal $(, $e:expr)*) => { Err(Error::from(format!($fmt $(, $e)*))) };
}
fn main() -> Result<(), Error> {
for filename in std::env::args().skip(1) {
println!("{}", filename);
let ru... | true |
e49ee02b6c30fd62608c0aad2e204d43a0366722 | Rust | GoXLR-on-Linux/goxlr-utility | /daemon/src/platform/unix.rs | UTF-8 | 876 | 2.765625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | use crate::events::EventTriggers;
use crate::DaemonState;
use anyhow::Result;
use log::debug;
use tokio::select;
use tokio::signal::unix::{signal, SignalKind};
use tokio::sync::mpsc;
pub async fn spawn_platform_runtime(
state: DaemonState,
tx: mpsc::Sender<EventTriggers>,
) -> Result<()> {
// This one's a ... | true |
7b34572bf6fbee487df3685703ca6190fb4e9326 | Rust | inrick/raytrace | /rs/src/ray.rs | UTF-8 | 9,449 | 2.875 | 3 | [] | no_license | use std::{ffi::OsStr, fs::File, io::Write, path::PathBuf};
use crate::vec::*;
pub struct Args {
pub nsamples: u32,
pub threads: u32,
pub cam: Camera,
pub scene: Scene,
}
pub struct Image {
pub buf: Vec<u8>,
pub nx: u32,
pub ny: u32,
}
fn rand32() -> f32 {
rand::random()
}
static PI: f32 = std::f32::consts:... | true |
3207771cfd48afab2eec392dcaa71c330d23a7af | Rust | abhikjain360/timaru | /timaru/src/setup.rs | UTF-8 | 899 | 2.640625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::{env, path::PathBuf};
use tokio::fs;
use crate::error::Error;
#[inline]
pub async fn config_dir() -> Result<PathBuf, Error> {
let cfg_dir = if let Ok(dir) = env::var("XDG_CONFIG_HOME") {
PathBuf::from(dir).join("timaru")
} else if let Ok(dir) = env::var("HOME") {
PathBuf::from(dir).j... | true |
364d3a107355f3732188fbf00feb07622545e8e4 | Rust | grapl-security/grapl | /src/rust/grapl-graphql-codegen/src/identification_algorithm.rs | UTF-8 | 1,591 | 2.9375 | 3 | [
"Apache-2.0"
] | permissive | use graphql_parser::schema::Directive;
/// Represents which algorithm is used to identify a node
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum IdentificationAlgorithm {
Session,
Static,
}
use std::convert::TryFrom;
use crate::{
constants::{
SESSION_ALGORITHM,
STATIC_ALGORITHM,
... | true |
92e171b27b48df0d77537cf1d48903af0907a958 | Rust | marcelo-a/fp-rust-book | /examples/book_04_01_04_reference/annotated_source.rs | UTF-8 | 321 | 3.28125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-public-domain",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA",
"LicenseRef-scancode-other-permissive",
"Unlicense"
] | permissive | fn main() {
let mut <tspan data-hash="1">s</tspan> = <tspan class="fn" data-hash="0" hash="2">String::from</tspan>("hello");
<tspan data-hash="1">s</tspan>.push_str(", world!"); // push_str() appends a literal to a String
println!("{}", <tspan data-hash="1">s</tspan>); // This will print `hello, world!`
}... | true |
7da66a97a31d624b4eac166bd9f3d02725ff8e6f | Rust | Yatekii/reactor | /reactor-derive/src/lib.rs | UTF-8 | 9,650 | 2.640625 | 3 | [] | no_license | #![recursion_limit="128"]
use quote::quote;
extern crate proc_macro;
extern crate proc_macro2;
use syn::parse::{
Parse,
ParseStream
};
#[derive(Debug, PartialEq)]
struct SubState {
ident: syn::Ident,
sub_states: Vec<SubState>,
}
impl Parse for SubState {
fn parse(input: ParseStream) -> syn::Res... | true |
49f239cb871bf02b9f57b419e68501a38067db3e | Rust | vangroan/vuur | /crates/vuur_parse/tests/test_pprint.rs | UTF-8 | 1,084 | 2.953125 | 3 | [
"MIT"
] | permissive | use vuur_parse::expr::Expr;
use vuur_parse::pprint::PrettyExpr;
use vuur_parse::stmt::{DefStmt, SimpleStmt};
const FG_GREEN: &str = "\x1b[32m";
const FG_RESET: &str = "\x1b[0m";
fn parse_expr(source_code: &str) -> Option<Expr> {
let mut module = vuur_parse::parse_str(source_code).expect("parsing test module");
... | true |
2cb309a8510185ab46564a4a633ca002d3e7cf3e | Rust | sflomenb/rust-book | /hello-world/src/main.rs | UTF-8 | 323 | 3.359375 | 3 | [] | no_license | fn main() {
println!("Hello, world!");
println!("{}", add2(2, 3))
}
fn add2(x: i32, y: i32) -> i32 {
x + y
}
#[cfg(test)]
mod tests {
// Note this useful idiom: importing names from outer (for mod tests) scope.
use super::*;
#[test]
fn test_add() {
assert_eq!(add2(1, 2), 3);
}... | true |
e8543b365e2f436956168a4401f21985109fca2f | Rust | mooman219/beryllium | /src/palette.rs | UTF-8 | 7,057 | 3.515625 | 4 | [
"Zlib"
] | permissive | use super::*;
/// An abstract RGBA color value.
///
/// * Each channel ranges from 0 (none) to 255 (maximum).
/// * Alpha channel is "opacity", so 255 is opaque.
///
/// A color value's exact representation within an image depends on the
/// [PixelFormat] of the image. You can use the "get" and "map" methods of a
/// ... | true |
be06eb79df6f1da7d70250b13c5d1f360cb0b3f5 | Rust | dejankos/AoC2020 | /src/day_13.rs | UTF-8 | 2,058 | 3.234375 | 3 | [] | no_license |
fn solve(input: (usize, Vec<usize>)) -> usize {
let ts = input.0;
let min = input
.1
.into_iter()
.map(|id| (find_first(id, ts), id))
.min_by_key(|p| p.0)
.unwrap();
(min.0 - ts) * min.1
}
fn solve_part_2(buses: Vec<(usize, usize)>) -> usize {
let (mut curr, ... | true |
500021d5a72a5ff7f04a96c7600aa2ab81fdf339 | Rust | nvzqz/bidiff | /crates/bidiff/src/enc.rs | UTF-8 | 904 | 2.734375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use super::Control;
use byteorder::{LittleEndian, WriteBytesExt};
use integer_encoding::VarIntWriter;
use std::io::{self, Write};
pub const MAGIC: u32 = 0xB1DF;
pub const VERSION: u32 = 0x1000;
pub struct Writer<W>
where
W: Write,
{
w: W,
}
impl<W> Writer<W>
where
W: Write,
{
pub fn new(mut w: W) -> ... | true |
0161ec0d3b26f69834342673a22381ee52b2b061 | Rust | isgasho/shine | /crates/shine-math/src/triangulation/traverse/edgecirculator.rs | UTF-8 | 2,428 | 2.765625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::geometry2::Position;
use crate::triangulation::graph::{Face, Triangulation, Vertex};
use crate::triangulation::query::{TopologyQuery, VertexClue};
use crate::triangulation::types::{FaceEdge, FaceIndex, Rot3, VertexIndex};
pub struct EdgeCirculator<'a, P, V, F, C>
where
P: Position,
V: Vertex<Positio... | true |
3df4b371a1de079ff460293a507a666fad07ff84 | Rust | PatrykStronski/KnapsackProblem | /src/main.rs | UTF-8 | 5,905 | 2.78125 | 3 | [] | no_license | mod task1;
mod task2;
mod random_population;
mod selection;
mod knap;
mod crossover;
mod mutation;
mod plot_results;
mod ant_colony;
fn evaluate_winner(knp: &knap::Knapsack, crossover_rate: f32, mutation_rate: f32, tournament_size: u32, population_size: u32, n: u32) -> u32{
let mut population = random_population::... | true |
e169f6cf2257500c6a4ef6c2bbcbc4bca2c996b1 | Rust | sgrif/derive_deref | /src/lib.rs | UTF-8 | 2,913 | 2.515625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate proc_macro;
extern crate proc_macro2;
#[macro_use]
extern crate quote;
extern crate syn;
use proc_macro::TokenStream;
use syn::{Path, Type, TypePath};
#[proc_macro_derive(Deref)]
pub fn derive_deref(input: TokenStream) -> TokenStream {
let item = syn::parse(input).unwrap();
let (field_ty, field_a... | true |
1a9d3bd81e02b0d032e4aba5171964a13c35cd8b | Rust | leejw51crypto/chain | /client-rpc/server/src/program.rs | UTF-8 | 4,606 | 2.609375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use structopt::StructOpt;
use crate::server::Server;
use std::env;
#[derive(StructOpt, Debug)]
#[structopt(
name = "client-rpc",
about = r#"JSON-RPC server for wallet management and blockchain query
ENVIRONMENT VARIABLES:
CRYPTO_GENESIS_FINGERPRINT Set the genesis fingerprint(Optional)
"#
... | true |
ec4fb0bc1b8cb4724ea54157bb0e50e61a54257e | Rust | moonmile/rust-sample | /src/ch06/sample-06-02/src/main.rs | UTF-8 | 1,331 | 3.828125 | 4 | [] | no_license | fn main() {
let v = vec![10,20,30,40,50] ;
// 全ての要素を繰り返す
print!("v is ");
for i in &v {
print!("{} ", i );
}
println!("");
// イテレータを使う
print!("v is ");
for i in v.iter() {
print!("{} ", i );
}
println!("");
// インデックス付きで繰り返す
print!("v is ");
for... | true |
04fc8f2e31dc6eb459a821ade9059dc4c27c9fff | Rust | slightknack/machine-110 | /src/cyclic.rs | UTF-8 | 1,121 | 3.40625 | 3 | [] | no_license | use std::fmt::Debug;
pub struct Cyclic {
pub state: Vec<bool>,
pub rules: Vec<Vec<bool>>,
}
impl Cyclic {
pub fn new(state: Vec<bool>, rules: Vec<Vec<bool>>) -> Cyclic {
Cyclic { state, rules }
}
pub fn step(&mut self) {
let rule = self.rules.remove(0);
if !self.state.is_e... | true |
2b10adcdf15548d15d09e1885ddbdcd734422612 | Rust | EdBuilds/holobone | /cli_runner/src/asteroids_game/collider.rs | UTF-8 | 585 | 2.6875 | 3 | [] | no_license | use specs_derive::Component;
use specs::prelude::*;
use lyon_path::Path;
#[derive(Clone, Copy)]
pub enum ColliderType{
Projectile,
Enemy,
Player
}
pub enum CollisionHandlerError{
MissingComponent,
NotImplemented,
}
//TODO: return the entities that needs to be deleted!
pub type CollisionHandler = ... | true |
8347f9a7db95c7413308f2ea7dcffefad6f3d864 | Rust | royswale/leetcode-cn | /maximum-subarray/rust/src/main.rs | UTF-8 | 1,504 | 3.765625 | 4 | [] | no_license | struct Solution {
}
impl Solution {
pub fn max_sub_array(nums: Vec<i32>) -> i32 {
let mut result: i32 = nums[0];
let mut sum: i32 = 0;
for num in nums {
if sum <= 0 {
sum = num;
} else {
sum += num;
}
if sum > r... | true |
e4c70cede93d493084213ab699c9207bb5392fbe | Rust | BartMassey/advent-of-code-2016 | /day08/soln.rs | UTF-8 | 5,567 | 2.84375 | 3 | [
"MIT"
] | permissive | // Copyright © 2016 Bart Massey
// This program is licensed under the "MIT License".
// Please see the file COPYING in this distribution
// for license terms.
//! Advent of Code Day 8.
/// Turn on for display tracing.
const TRACING: bool = false;
extern crate aoc;
#[macro_use]
extern crate lazy_static;
extern crate ... | true |
8a7b716d30460bc8eb3ccdfdf8e4d86f1fe781a4 | Rust | dinfuehr/dora | /dora-frontend/src/implck.rs | UTF-8 | 6,112 | 2.578125 | 3 | [
"MIT"
] | permissive | use std::collections::{HashMap, HashSet};
use crate::error::msg::ErrorMessage;
use crate::sema::Sema;
pub fn check(sa: &mut Sema) {
for impl_ in sa.impls.iter() {
let impl_for = {
let impl_ = impl_.read();
let trait_ = sa.traits[impl_.trait_id()].read();
let all: HashS... | true |
9c4e9c00d851de42b68beb0a108fc2fc683f8eeb | Rust | wnz27/vim-clap | /crates/types/src/query.rs | UTF-8 | 1,083 | 2.96875 | 3 | [
"MIT"
] | permissive | use crate::search_term::{ExactTerm, FuzzyTerm, InverseTerm, SearchTerm, TermType};
#[derive(Debug, Clone)]
pub struct Query {
pub fuzzy_terms: Vec<FuzzyTerm>,
pub exact_terms: Vec<ExactTerm>,
pub inverse_terms: Vec<InverseTerm>,
}
impl From<&str> for Query {
fn from(query: &str) -> Self {
let ... | true |
e75fa6c230155df1a896925b075b562610d03ea6 | Rust | KaiserY/trpl-zh-cn | /listings/ch14-more-about-cargo/listing-14-05/src/lib.rs | UTF-8 | 862 | 3.328125 | 3 | [
"MIT"
] | permissive | // ANCHOR: here
//! # Art
//!
//! A library for modeling artistic concepts.
pub use self::kinds::PrimaryColor;
pub use self::kinds::SecondaryColor;
pub use self::utils::mix;
pub mod kinds {
// --snip--
// ANCHOR_END: here
/// The primary colors according to the RYB color model.
pub enum PrimaryColor {... | true |
bc9efe0336f1d8edbecf501f91ac8d6f259ea5ff | Rust | ryo97321/rust-workspace | /yukicoder/level1/no79.rs | UTF-8 | 1,277 | 3.265625 | 3 | [] | no_license | use std::collections::HashMap;
fn getline() -> String {
let mut __ret = String::new();
std::io::stdin().read_line(&mut __ret).ok();
return __ret;
}
fn main() {
let n: usize = getline().trim().parse().unwrap();
let line = getline();
let params: Vec<_> = line.trim().split(' ').collect();
l... | true |
46b26999598d6e50147803f306da8e667b0c2f65 | Rust | PsypherPunk/advent-of-code | /2017/21/src/main.rs | UTF-8 | 634 | 2.828125 | 3 | [
"BSD-3-Clause"
] | permissive | use std::fs;
use ::day21::*;
use std::str::FromStr;
fn main() {
let input = fs::read_to_string("input.txt").expect("Error reading input.txt");
let rules = Rules::from_str(&input).unwrap();
let mut image = Image::new();
for _ in 0..5 {
image = image.get_iteration(&rules);
}
println!(
... | true |
67da26377ddcceb6a950825cc2caf765262c335b | Rust | diogobaeder/eulerust | /p019/src/main.rs | UTF-8 | 4,358 | 4.03125 | 4 | [
"BSD-2-Clause"
] | permissive | #[derive(Debug)]
struct Date {
year: u32,
month: u8,
day: u8,
week_day: u8,
}
impl Date {
fn new() -> Date {
Date {
year: 1900,
month: 1,
day: 1,
week_day: 2,
}
}
fn add(&mut self) {
self.day += 1;
self.week_da... | true |
d9cf925cf97bff4979eb0082d8d82c98f93ca965 | Rust | BenBergman/advent-of-code-2019 | /src/bin/aoc02.rs | UTF-8 | 4,544 | 2.875 | 3 | [] | no_license | use itertools::repeat_n;
use itertools::Itertools;
fn main() {
let original_intcode = vec![
1, 0, 0, 3, 1, 1, 2, 3, 1, 3, 4, 3, 1, 5, 0, 3, 2, 1, 6, 19, 1, 5, 19, 23, 1, 23, 6, 27, 1,
5, 27, 31, 1, 31, 6, 35, 1, 9, 35, 39, 2, 10, 39, 43, 1, 43, 6, 47, 2, 6, 47, 51, 1, 5, 51,
55, 1, 55, 13, ... | true |
521004509ef58b36d3ab5d3fd5672bbf8aaa47fa | Rust | reproto/reproto | /lib/path-lexer/path_lexer.rs | UTF-8 | 5,709 | 3.34375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Lexer for paths.
use crate::errors::{Error, Result};
use crate::path_token::PathToken;
use std::str::CharIndices;
pub struct PathLexer<'input> {
source: CharIndices<'input>,
source_len: usize,
source_str: &'input str,
n0: Option<(usize, char)>,
n1: Option<(usize, char)>,
buffer: String,
... | true |
3a98cb4b33fe73a0fe207d0b4bcb2a17357171bf | Rust | zrma/1d1rust | /src/boj/p10k/p10157.rs | UTF-8 | 3,954 | 3.21875 | 3 | [] | no_license | #[allow(dead_code)]
fn solve10157(col: i32, row: i32, k: i32) -> (i32, i32, bool) {
if row * col < k {
return (0, 0, false);
}
let mut x = 1;
let mut y = 1;
let mut k0 = k - 1;
let mut col0 = col - 1;
let mut row0 = row;
let mut dir = Direction::Up;
loop {
match dir... | true |
8d8c77cbdf49dda75de5a9cfe8fa96e6fe11a996 | Rust | zarik5/bridgevr-dev | /bridgevr/vulkan_test/src/main.rs | UTF-8 | 1,813 | 2.78125 | 3 | [] | no_license | mod graphics;
use bridgevr_common::*;
use graphics::*;
use safe_transmute::*;
use std::{mem::size_of, sync::Arc};
const TRACE_CONTEXT: &str = "Main";
const IMAGE_SIZE: (u32, u32) = (3200, 2400);
#[derive(Debug)]
struct Hello {}
fn run() -> StrResult {
println!("Starting...");
let context = Arc::new(trace_e... | true |
2527bfa7a5c5068b70ace6bb6cf5db7291d06903 | Rust | Cheshulko/Algorithms | /Leetcode/LongestCycleinaGraph.rs | UTF-8 | 1,317 | 3.15625 | 3 | [] | no_license | // https://leetcode.com/problems/longest-cycle-in-a-graph
struct Graph {
edges: Vec<i32>,
data: Vec<(i32, i32, bool)>,
ans: i32,
}
impl Graph {
fn new(edges: Vec<i32>) -> Self {
let cnt = edges.len();
Graph {
edges,
data: vec![(0, 0, false); cnt],
an... | true |
154c0a5aebd53d3ab309b5c53e86768102ffa26f | Rust | huonw/slow_primes | /src/fast_sieve.rs | UTF-8 | 4,117 | 3.171875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #![allow(dead_code)]
use bit::{BitVec};
use std::{cmp};
use Primes;
/// A segmented sieve that yields only a small run of primes at a
/// time.
///
/// This is heavily inspired by this [segmented
/// sieve](http://primesieve.org/segmented_sieve.html) code.
#[derive(Debug)]
pub struct StreamingSieve {
small: Prim... | true |
2764a27682113506086426ae4939e90e4dbe3073 | Rust | dfinke/MultiLanguagePSCrescendo | /RustAndCrescendo/hello.rs | UTF-8 | 233 | 3.046875 | 3 | [] | no_license | use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
let name = &args[1];
let age = &args[2];
println!("name = {}", name);
println!("age = {}", age);
println!("language = Rust");
} | true |
eed08dae7878fbfa5369daaeac4430821a310a81 | Rust | Goliworks/Roma | /src/utils.rs | UTF-8 | 392 | 2.96875 | 3 | [] | no_license | use dirs::home_dir;
pub fn host_to_domain(host: String) -> String {
let domain: Vec<&str> = host.split(":").collect();
domain[0].to_string()
}
pub fn resolve_path(path: String) -> String {
let spl: Vec<&str> = path.split("~/").collect();
if spl[0].is_empty() && spl.len() > 1 {
return format!("... | true |
150afa889edda70ce636ef13d19cab351d32080b | Rust | RWTH-OS/rust-x86 | /src/bits32/irq.rs | UTF-8 | 1,923 | 2.984375 | 3 | [
"MIT"
] | permissive | //! Interrupt description and set-up code.
use shared::descriptor::*;
use shared::paging::VAddr;
use shared::PrivilegeLevel;
/// An interrupt gate or trap gate descriptor.
///
/// See Intel manual 3a for details, specifically section 6.11.
#[derive(Debug, Copy, Clone)]
#[repr(C, packed)]
pub struct IdtEntry {
///... | true |
1b3c694ee91874fb216e7301b5c10b76949c7ffb | Rust | glium/glium | /src/program/compute.rs | UTF-8 | 8,074 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | use crate::gl;
use crate::context::CommandContext;
use crate::backend::Facade;
use std::fmt;
use std::collections::hash_map::{self, HashMap};
use std::os::raw;
use std::hash::BuildHasherDefault;
use fnv::FnvHasher;
use crate::CapabilitiesSource;
use crate::GlObject;
use crate::ProgramExt;
use crate::Handle;
use cra... | true |
29595e4893a4998c6483603bcec79812837bfa4e | Rust | jhspetersson/fselect | /src/fileinfo.rs | UTF-8 | 405 | 2.578125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-free-unknown"
] | permissive | use zip;
use zip::DateTime;
pub struct FileInfo {
pub name: String,
pub size: u64,
pub mode: Option<u32>,
pub modified: DateTime,
}
pub fn to_file_info(zipped_file: &zip::read::ZipFile) -> FileInfo {
FileInfo {
name: zipped_file.name().to_string(),
size: zipped_file.size(),
... | true |
d6c40fa9848c2e2418579752d14f5ef856d7b5f2 | Rust | burrbull/stm32f1-gates | /src/stm32f107/dma1/isr.rs | UTF-8 | 14,781 | 2.921875 | 3 | [] | no_license | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
impl super::ISR {
#[doc = r" Reads the contents of the register"]
#[inline]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
}
#[doc = "Possible values of the field `GIF1`"]
#[derive(Clone, ... | true |
c3194b3fc108afde73042f25c19221cf1d9c6ba1 | Rust | dennisss/dacha | /pkg/image/src/format/jpeg/stuffed.rs | UTF-8 | 1,652 | 3.203125 | 3 | [
"Apache-2.0"
] | permissive | use std::io::{Read, Write};
pub struct StuffedReader<'a, T: Read> {
inner: &'a mut T,
}
impl<'a, T: Read> StuffedReader<'a, T> {
pub fn new(inner: &'a mut T) -> Self {
Self { inner }
}
}
impl<'a, T: Read> Read for StuffedReader<'a, T> {
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<us... | true |
4ee1291ee4d308cf71c2bdfdeb7f0bf8d6801ddc | Rust | vorner/spirit | /src/app.rs | UTF-8 | 5,881 | 3.21875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! The running application part.
//!
//! The convenient way to manage the application runtime is through
//! [`Builder::run`][crate::SpiritBuilder::run]. If more flexibility is needed, the
//! [`Builder::build`][crate::SpiritBuilder::build] can be used instead. That method returns the
//! [`App`][crate::app::App] obje... | true |
2b7587c1e7bb7bd55ddc38f1c69b12239962b039 | Rust | Stanislav-Lapata/oxide-auth | /src/frontends/rouille.rs | UTF-8 | 3,869 | 2.734375 | 3 | [
"MIT"
] | permissive | //! Offers bindings for the code_grant module with rouille servers.
//!
//! Following the simplistic and minimal style of rouille, this module defines only the
//! implementations for `WebRequest` and `WebResponse` and re-exports the available flows.
extern crate rouille;
extern crate serde_urlencoded;
use std::borrow... | true |
ea7da728d5d91ba8b1c6d1e10950d7368b8d3992 | Rust | d3v3l0/futuretea-whyrust | /jsonserde/src/main.rs | UTF-8 | 912 | 2.515625 | 3 | [] | no_license |
use serde::*;
use serde_json;
#[derive(Serialize,Deserialize,Debug,Clone)]
struct Student(String);
#[derive(Serialize,Deserialize,Debug,Clone)]
struct Professor(String);
#[derive(Serialize,Deserialize,Debug,Clone)]
struct FutureData {
phd_students: Vec<Student>,
professors: Vec<Professor>,
}
fn main() {
... | true |
956068f01f7420079c84753bb095ed034c8dfc08 | Rust | uiamn/tar_archiver | /src/main.rs | UTF-8 | 3,988 | 2.75 | 3 | [] | no_license | use std::io::Write;
use std::io::Read;
use std::os::unix::fs::MetadataExt;
struct Header {
name: String,
mode: String,
uid: u32,
gid: u32,
mtime: u64,
typeflag: [char; 1],
size: u64
}
fn octal(n: u64, pad: usize) -> String {
format!("{:0>pad$}", format!("{:o}", n), pad=pad)
}
// TOD... | true |
d2b2ddc124305897129599296834f9e7c4c65ea3 | Rust | aylax/mathze | /recursion/backtracking/n_queens/solution.rs | UTF-8 | 815 | 3.15625 | 3 | [
"MIT"
] | permissive | impl Solution {
pub fn total_n_queens(n: i32) -> i32 {
queen(n).len() as i32
}
}
type Queen = Vec<Vec<i32>>;
fn queen(n: i32) -> Queen {
de(n, n)
}
fn de(n: i32, u: i32) -> Queen {
if u == 0 {
return vec![vec![]];
}
de(n, u - 1)
.iter()
.map(|xs| {
... | true |
525c1df73f46695ada35169523655e78522911ef | Rust | mobilipia/milestone-core | /cli/src/lib.rs | UTF-8 | 11,813 | 2.6875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2020 The Exonum Team
//
// 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to i... | true |
6381f931368c582d327147fbdfd4b06343c205bd | Rust | aQaTL/advent_of_code_2019 | /day_18/src/main.rs | UTF-8 | 2,248 | 3.1875 | 3 | [] | no_license | use bit_set::BitSet;
use std::collections::{HashMap, HashSet, VecDeque};
fn main() {
let input = std::fs::read_to_string("day_18/input.txt").unwrap();
let mut grid = HashMap::<(i64, i64), char>::new();
let mut keys = Vec::<char>::new();
let mut start = (0, 0);
{
let (mut x, mut y) = (0, 0);
for cell in input.... | true |
d6d213aaadb7f5497715d5c43b82213e2a3874eb | Rust | GreenPix/lycan | /src/actor/mob.rs | UTF-8 | 1,979 | 2.625 | 3 | [] | no_license | use std::collections::HashSet;
use std::fmt::{self,Debug,Formatter};
use behaviour_tree::tree::BehaviourTreeNode;
use id::Id;
use actor::ActorId;
use entity::{Entity,EntityStore};
use messages::{self,Command,Notification,EntityOrder};
use scripts::{BehaviourTree};
use ai::{BehaviourTreeData,Context};
pub struct AiAct... | true |
ecc2bc0036f219bac1dd3b57dbee836d109e7aa3 | Rust | dprint/dprint | /crates/dprint/src/plugins/cache_manifest.rs | UTF-8 | 11,262 | 2.609375 | 3 | [
"MIT"
] | permissive | use serde::Deserialize;
use serde::Serialize;
use std::collections::HashMap;
use std::path::PathBuf;
use anyhow::Result;
use dprint_core::plugins::PluginInfo;
use super::implementations::WASMER_COMPILER_VERSION;
use crate::environment::Environment;
const PLUGIN_CACHE_SCHEMA_VERSION: usize = 8;
#[derive(Clone, Seria... | true |
1e67f710bc791c76bce0ade83f0d7c5090d255e8 | Rust | burdges/lake | /Xolotl/src/keys/implicit.rs | UTF-8 | 751 | 2.671875 | 3 | [] | no_license | //! TODO: An [implicit certificate](https://en.wikipedia.org/wiki/Implicit_certificate)
//! scheme could shave 32 bytes off the `ROUTING_KEY_CERT_LENGTH`.
//! We must know that someone who compramises the node's long term
//! certificate for issuing routing keys, and some routing keys,
//! cannot compute later routing... | true |
d60c44a55dabc8a17636f0153391fc9172d57f67 | Rust | anotak/riftwizardstats | /src/main.rs | UTF-8 | 7,647 | 2.609375 | 3 | [
"MIT"
] | permissive |
mod parse;
mod types;
mod hashmap;
use crate::parse::*;
use crate::types::{Run,Realm, MergedRuns, Outcome};
use crate::hashmap::*;
use crate::hashmap::HashMapExtensions;
use clap::{crate_authors, crate_version};
use std::fs;
use std::path::*;
use std::io;
use std::io::BufRead;
use std::collections::HashMap;
use std... | true |
6cb441452784f20a491656c3909996505a94b70b | Rust | mcarton/strfmt | /src/fmtf64.rs | UTF-8 | 2,124 | 2.984375 | 3 | [
"MIT"
] | permissive | use std::fmt::Write;
use std::string::String;
use types::*;
use formatter::Formatter;
/// implement formatting of f64
impl<'a, 'b> Formatter<'a, 'b> {
/// format the given string onto the buffer
pub fn f64(&mut self, f: f64) -> Result<()> {
let ty = match self.ty() {
None => 'f',
... | true |
0a5647783327b07775b8fd0a3540d65dc203227f | Rust | isidornygren/ogaboga | /src/sequencer/mod.rs | UTF-8 | 2,568 | 2.765625 | 3 | [
"MIT"
] | permissive | use std::{thread, time::Instant};
pub mod generator;
use crate::rhythm::RhythmController;
// mod pool;
// mod sequencer_thread;
#[derive(Clone)]
pub enum SequenceStep {
None,
Beat,
Freq(f32),
Amp(f32),
FreqAmp(f32, f32),
}
pub type Sequence = Vec<SequenceStep>;
pub struct Sequencer {
sequences: Ve... | true |
fa08e65121a6743c128294d43464ce7346badffe | Rust | ViniciosLugli/vcargo | /src/cargo/mod.rs | UTF-8 | 903 | 2.9375 | 3 | [
"MIT"
] | permissive | use ansi_term::Colour;
use std::process::Command;
pub struct CargoCommand {
pub default_command: &'static str,
}
pub trait Cargo {
fn run(&self, args: Vec<String>) -> bool;
}
impl Cargo for CargoCommand {
fn run(&self, args: Vec<String>) -> bool {
let mut init_cmd: Command = Command::new(self.defa... | true |
3c5c311e75c058019e17e70a2a96cc5fc12b51b0 | Rust | dxfrontiers/sudoku_verifier_rust | /src/main.rs | UTF-8 | 3,908 | 3.390625 | 3 | [] | no_license | use std::env;
use std::fs::File;
use std::io::{BufReader, BufRead, Error, ErrorKind, Read};
use std::convert::TryInto;
use rayon::prelude::*;
/**
A struct holding a 9x9 filed sudoku board
*/
struct Sudoku{
fields: [u8;81]
}
/**
Provide implementations for different views into the data structure
Sinc... | true |
41a899337b67b6d19f5f4406dffc6ec4079e90f3 | Rust | overthink/pt | /src/vector.rs | UTF-8 | 1,958 | 3.53125 | 4 | [] | no_license | use std::ops::{Add, Mul, Neg, Sub};
#[derive(Copy, Clone, Debug)]
#[repr(C)]
pub struct Vector3 {
pub x: f64,
pub y: f64,
pub z: f64,
}
impl Vector3 {
pub fn zero() -> Vector3 {
Vector3 {
x: 0.0,
y: 0.0,
z: 0.0,
}
}
// aka manitude, Eudclidi... | true |
2cc5f015f1c01041f3d395dc28dc96c58f8c18cb | Rust | flier/rust-atomic-traits | /src/lib.rs | UTF-8 | 12,346 | 3.53125 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | //! The traits for generic atomic operations
//!
//! # Compatibility
//!
//! The crate is tested for rustc 1.8 and greater.
//!
//! # Example
//!
//! ```
//! # extern crate num_traits;
//! # extern crate atomic_traits;
//! use std::sync::atomic::{AtomicUsize, Ordering};
//!
//! use num_traits::One;
//! use atomic_trait... | true |
54eb4ecc94e9dc7dca044fc13237a33b6eb17c59 | Rust | portier/portier-broker | /src/config/i18n.rs | UTF-8 | 882 | 2.765625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use gettext::Catalog;
use std::fs::File;
use std::path::PathBuf;
// Contains all gettext catalogs we use in compiled form.
pub struct I18n {
pub catalogs: Vec<(&'static str, Catalog)>,
}
const SUPPORTED_LANGUAGES: &[&str] = &["en", "de", "nl"];
impl I18n {
pub fn new(data_dir: &str) -> I18n {
let dat... | true |
18d96e54b01efdd447943ff908321c97e44caa51 | Rust | Caluka/CHIP8 | /src/chip8.rs | UTF-8 | 1,525 | 3.03125 | 3 | [] | no_license | use super::bus;
use super::cpu;
use std::time::Instant;
pub struct Chip8 {
pub cpu: cpu::Cpu,
pub bus: bus::DataBus,
pub delay_timer: std::time::Instant,
}
impl Chip8 {
pub fn new() -> Self {
Self {
cpu: cpu::Cpu::new(),
bus: bus::DataBus::new(),
... | true |
862870a94465e1c5cefc9b3d6767e9f50fe69409 | Rust | glpeon/rpfm | /rpfm_ui/src/shortcuts_ui/slots.rs | UTF-8 | 1,826 | 2.578125 | 3 | [
"MIT"
] | permissive | //---------------------------------------------------------------------------//
// Copyright (c) 2017-2020 Ismael Gutiérrez González. All rights reserved.
//
// This file is part of the Rusted PackFile Manager (RPFM) project,
// which can be found here: https://github.com/Frodo45127/rpfm.
//
// This file is licensed un... | true |
c6e21e0d019042ace77543af06f938e583ad06a7 | Rust | DanglingPointer/rust-ttt | /src/grid.rs | UTF-8 | 7,538 | 3.296875 | 3 | [] | no_license | use std::fmt;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum Mark {
Cross,
Nought,
}
#[derive(Default, Debug)]
pub struct Grid {
side_length: usize,
data: Vec<Option<Mark>>,
}
impl Grid {
pub fn new(side_length: usize) -> Grid {
Grid {
side_length,
data: vec... | true |
4955462dbed7c406a7173fdf672cf2db351bd2d8 | Rust | Pedrotojal/automaat | /src/web-client/src/component/task_result.rs | UTF-8 | 3,106 | 3.171875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! A single task result shown in the UI when searching for tasks.
use crate::model::task::Task;
use crate::router::Route;
use dodrio::bumpalo::collections::string::String;
use dodrio::bumpalo::format;
use dodrio::{Node, Render, RenderContext};
use std::marker::PhantomData;
/// The `TaskResult` component.
pub(crate) ... | true |
2e760c79608c5c5192e89fb7ea665ade3a057cd9 | Rust | ngtkana/aribook | /crates/chap3_4/number_of_length_k_paths/src/main.rs | UTF-8 | 2,806 | 2.859375 | 3 | [] | no_license | // dbg {{{
#[allow(dead_code)]
mod dbg {
use std::fmt::{Debug, Formatter};
#[derive(Clone)]
pub struct Tabular<'a, T: Debug>(pub &'a [T]);
impl<'a, T: Debug> Debug for Tabular<'a, T> {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
for i in 0..self.0.len() {
... | true |
2159c7d59ed1927e1e2d5fe59dd0239a90d43a2e | Rust | stillmatic/advent | /2021/d1/src/main.rs | UTF-8 | 1,079 | 3.234375 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::Path;
fn main() {
// let lines = numbers_from_file("../input.txt");
// let file_name = "../example.txt";
let file_name = "../input.txt";
let input_str = std::fs::read_to_string(file_name).unwrap();
let lines: Vec<i32> = input_str... | true |
e213ea95d72d66371b9cf895faf18729193dd31b | Rust | TrendingTechnology/ruzzt | /ruzzt_engine/src/sounds.rs | UTF-8 | 4,383 | 2.984375 | 3 | [
"MIT"
] | permissive | use lazy_static::lazy_static;
lazy_static! {
/// When playing a sound effect, it takes one of these arrays depending on the selected sound effect
/// index, then it toggles the speaker for (1/sample) seconds. Eg. for index 1, the speaker might be
/// up for 1/1100 seconds, then down for 1/1200 seconds, then up for ... | true |
d49284b61584e4bf25778ef80f4b451d8bda1467 | Rust | NiklasBorson/AdventDayOfCode2020 | /day15/src/main.rs | UTF-8 | 1,469 | 3.71875 | 4 | [] | no_license | use std::collections::HashMap;
fn main() {
let input = [ 0, 14, 1, 3, 7, 9 ];
let mut game = GameState::new(&input);
// Part 1
game.advance_to(2020);
println!("{}", game.last_number);
// Part 2
game.advance_to(30000000);
println!("{}", game.last_number);
}
struct GameState {
next... | true |
f8c0f1ed927dafc263b98cc3449dd9d17060040b | Rust | davidB/kubectl-view-allocations | /src/qty.rs | UTF-8 | 11,377 | 2.96875 | 3 | [
"CC0-1.0"
] | permissive | // see [Definitions of the SI units: The binary prefixes](https://physics.nist.gov/cuu/Units/binary.html)
// see [Managing Compute Resources for Containers - Kubernetes](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/)
//TODO rewrite to support exponent, ... see [apimachinery/quant... | true |
9e5a77a6d8679c749b261f7437800d434bcd30e6 | Rust | ggez/ggez | /examples/blend_modes.rs | UTF-8 | 6,671 | 3.0625 | 3 | [
"MIT"
] | permissive | //! An example drawing semi-transparent venn diagrams
//! using different blend modes.
//!
//! It also shows why you'd usually want to draw canvases
//! using the `Premultiplied` blend mode
//! (for more explanations on this see https://github.com/ggez/ggez/issues/694#issuecomment-853724926)
use ggez::context::HasMut;... | true |
d67a945ef10739e44adc67a92bba19c068e4de98 | Rust | AntonGepting/tmux-interface-rs | /src/commands/status_line/display_message.rs | UTF-8 | 5,888 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use crate::commands::constants::*;
use crate::TmuxCommand;
use std::borrow::Cow;
/// Structure for displaying a message
///
/// # Manual
///
/// tmux ^3.2:
/// ```text
/// display-message [-aINpv] [-c target-client] [-d delay] [-t target-pane] [message]
/// (alias: display)
/// ```
///
/// tmux ^3.0:
/// ```text
/// ... | true |
cb6fc63d42c28ee501db31e6bd928dfbecebcc13 | Rust | Mr-Llama-s-Wonderful-Soundboard/mlws_lib | /src/sound/source.rs | UTF-8 | 2,432 | 2.875 | 3 | [] | no_license | // Initial version from Rodio APACHE LICENSE 2.0
//! Sources of sound and various filters.
use std::time::Duration;
use super::sample::Sample;
///
pub trait Source: Iterator
where
Self::Item: Sample,
{
/// Returns the number of samples before the current frame ends. `None` means "infinite" or
/// "until... | true |
b7fdfaa6aadbfd93dd701ad2cd9b7c3be2abcf58 | Rust | jkatajamki/rust-stuff | /chapter-three/fib.rs | UTF-8 | 449 | 3.578125 | 4 | [] | no_license | const NUM_OF_ELEMENTS: usize = 20;
fn main() {
// calculate fib sequence for NUM_OF_ELEMENTS elements
let mut fib_seq = vec![1, 1];
for x in 2..NUM_OF_ELEMENTS {
let prev_i = fib_seq[x - 1];
let prev_of_prev_i = fib_seq[x - 2];
let next_num = prev_i + prev_of_prev_i;
fib_seq.push(next_num);
}
... | true |
7efb98add9e09ff228483fb9b90240a7e2dd751d | Rust | etalab/transport-validator | /src/validators/fare_attributes.rs | UTF-8 | 3,416 | 2.96875 | 3 | [
"MIT"
] | permissive | use crate::issues::*;
pub fn validate(gtfs: >fs_structures::Gtfs) -> Vec<Issue> {
let missing_price = gtfs
.fare_attributes
.values()
.filter(empty_price)
.map(|fare_attributes| make_issue(fare_attributes, IssueType::MissingPrice));
let invalid_currency = gtfs
.fare_at... | true |
9ef7ed4e89e50707094772fb35e5b912635bb2e9 | Rust | study-core/my-rust-coding-studing | /src/typeTest.rs | UTF-8 | 281 | 2.828125 | 3 | [] | no_license | fn main() {
let a : usize = 12;
println!(a);
let u = User{
username: "ss",
email: "sd",
sign_in_count: 45,
active: false,
};
}
struct User {
username: String,
email: String,
sign_in_count: u64,
active: bool,
} | true |
3a09af30291ad81f13bc65e61a86878fc1501cb1 | Rust | OzieGamma/RustWorkShopEPFL12Nov2014 | /hello_world/src/main.rs | UTF-8 | 52 | 2.796875 | 3 | [] | no_license | fn main() {
let x = 5i;
let y = 6i;
x + y;
}
| true |
3f8cf02e7f3216e3561e48fa82f25c86b8bc4b74 | Rust | doytsujin/yew | /packages/yew-macro/src/function_component.rs | UTF-8 | 14,403 | 2.6875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use proc_macro2::{Span, TokenStream};
use quote::{quote, ToTokens};
use syn::parse::{Parse, ParseStream};
use syn::punctuated::Punctuated;
use syn::token::{Comma, Fn};
use syn::{
parse_quote, parse_quote_spanned, visit_mut, Attribute, Block, FnArg, Generics, Ident, Item,
ItemFn, LitStr, ReturnType, Type, Visibi... | true |
bf68e16f98d72b61842e620fad8aa23fee743487 | Rust | lelandbatey/rust_buddhabrot | /trajectory-gen/src/main.rs | UTF-8 | 6,544 | 3.171875 | 3 | [] | no_license | extern crate argparse;
extern crate rand;
extern crate serde;
extern crate serde_json;
extern crate time;
extern crate buddhabrot;
use std::collections::HashMap;
use std::sync::mpsc::{channel, Sender};
use std::thread;
use std::time::Duration;
use argparse::{ArgumentParser, Store};
use buddhabrot::buddha::{Complex, ... | true |
9d964503ad87bc8c5de75bae691163f792cddf4a | Rust | moisutsu/rsa | /src/main.rs | UTF-8 | 1,701 | 2.625 | 3 | [] | no_license | use clap::Clap;
use rsa::Opt;
use std::ops::*;
#[allow(clippy::clippy::many_single_char_names)]
fn main() {
let opt = Opt::parse();
let p = opt.p;
let q = opt.q;
let n = p * q;
let l = (p - 1) * (q - 1);
let m = opt.plaintext;
println!("Plaintext = {}", m);
println!("p = {}, q = {}", p... | true |
d8c749ff262d03c528691ac8895d870b290c58e4 | Rust | xyzith/rust_practice | /datatype/src/main.rs | UTF-8 | 420 | 3.59375 | 4 | [] | no_license | fn main() {
// Note that char literals are specified with single quotes, as opposed to string literals, which use double quotes.
let emoji = '😎';
println!("emoji char test {}", emoji);
//tuple
let tup: (i32, f64, u8) = (500, 6.4, 1);
let (_x, y, _z) = tup;
println!("y = {}", y);
println!("y = {}", tup.1);
le... | true |
4a134a92983fef0cf7dd16d521016a7d73c40c49 | Rust | sgrowe/advent-of-code-2020 | /src/day_eighteen.rs | UTF-8 | 4,416 | 3.4375 | 3 | [] | no_license | use super::utils::start_day;
use std::iter::Peekable;
use std::str::CharIndices;
pub fn main() {
let input = start_day("eighteen");
println!("Part one: {}", part_one(&input));
println!("Part two: {}", part_two(&input));
println!();
}
fn part_one(input: &str) -> u64 {
input
.lines()
... | true |
7df5d58e46ad97344638262d63357c5f87d00e4b | Rust | chastell/talks | /balkan-ruby-2018/code/popcount_rust/src/lib.rs | UTF-8 | 1,213 | 3 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate helix;
ruby! {
class Popcount {
def count(int: u64) -> u32 {
int.count_ones()
}
}
class HTML {
def map_escape(input: String) -> String {
input.chars().map(|chr| {
match chr {
'<' => String::from(... | true |
3d520a5426f2f66edd0d918410608d3f403abba2 | Rust | iMplode-nZ/ul-test | /src/fs.rs | UTF-8 | 1,318 | 2.59375 | 3 | [] | no_license | use crate::conversions::from_ul_string;
use std::os::raw::c_char;
use std::os::raw::c_longlong;
use ul_sys::*;
#[allow(unused_variables)]
unsafe extern "C" fn file_exists(path: ULString) -> bool {
println!("Finding: {:?}", from_ul_string(path));
false
}
#[allow(unused_variables)]
unsafe extern "C" fn get_file_... | true |
b972c32cec851b1f233bf72e6e1f3e873d2d3e7a | Rust | isgasho/cargo-sort-ck | /src/main.rs | UTF-8 | 5,818 | 2.921875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use std::env;
use std::fs::{read_to_string, OpenOptions};
use std::io::Write;
use std::path::PathBuf;
use clap::{App, Arg};
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
use toml_parse::{parse_it, sort_toml_items, Formatter, Matcher, SyntaxNodeExtTrait};
const HEADERS: [&str; 3] = [
... | true |
529625d388058a2cbeeddaef6327100fce8c96b0 | Rust | puzza007/ErlangRT | /src/emulator/disasm.rs | UTF-8 | 1,419 | 2.5625 | 3 | [
"MIT"
] | permissive | use beam::gen_op;
use emulator::code::{CodePtr, opcode, Labels, RefCode};
use emulator::code_srv::CodeServer;
use rt_defs::Word;
use term::lterm::*;
/// Print to screen disassembly of the current function.
#[allow(dead_code)]
pub unsafe fn disasm(code: RefCode, _labels: Option<&Labels>,
code_serv... | true |
f1410cf45339972d2c130cbdb44664136e197d9c | Rust | pantsbuild/pants | /src/rust/engine/options/src/env.rs | UTF-8 | 1,883 | 2.640625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
use std::collections::HashMap;
use std::env;
use super::id::{NameTransform, OptionId, Scope};
use super::OptionsSource;
use crate::parse::{parse_bool, parse_string_list};
use crate::Lis... | true |
f7a06fddf983fa734f90e97ac211fcba8f6089ba | Rust | nicolasjhampton/rust-server-framework | /http/src/response_mod/status.rs | UTF-8 | 4,193 | 3.09375 | 3 | [] | no_license | use std::fmt;
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum Status {
CODE1(u8),
CODE2(u8),
CODE3(u8),
CODE4(u8),
CODE5(u8),
INFO,
SUCCESS,
REDIRECT,
BAD,
ERROR
}
impl fmt::Display for Status {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let (code, me... | true |
8e94f4d5c8073df69e610f6b0d080bb05cd73a71 | Rust | deniauma/Neatro | /simple-alloc/src/alloc.rs | UTF-8 | 1,440 | 2.65625 | 3 | [] | no_license | use core::mem::{size_of, align_of};
use core::ffi::c_void;
use win32::{HANDLE, GetProcessHeap, HeapAlloc, HeapFree};
pub struct Layout
{
pub size: usize,
pub align: usize,
}
impl Layout
{
pub fn new(size: usize) -> Self
{
Self
{
size,
align: 4,
}
}
... | true |
dd8d2a3bb832f97972a111fdda11a0e6b6279c27 | Rust | csssuf/rust-gpg-error | /src/lib.rs | UTF-8 | 7,948 | 2.96875 | 3 | [] | no_license | extern crate libgpg_error_sys as ffi;
use std::borrow::Cow;
use std::error;
use std::ffi::{CStr, NulError};
use std::fmt::{self, Write};
use std::io::{self, ErrorKind};
use std::os::raw::c_int;
use std::result;
use std::str;
pub type ErrorSource = ffi::gpg_err_source_t;
pub type ErrorCode = ffi::gpg_err_code_t;
/// ... | true |
02c1efa7b54997e4b49b4d4687a3505da280b604 | Rust | prz23/zinc | /zinc-vm/src/gadgets/auto_const.rs | UTF-8 | 1,737 | 2.828125 | 3 | [
"Apache-2.0"
] | permissive | //!
//! The constant optimizing macro.
//!
pub mod prelude {
pub use crate::constraint_systems::constant::Constant as ConstantCS;
pub use crate::gadgets::scalar::variant::Variant as ScalarVariant;
pub use crate::gadgets::scalar::Scalar;
use crate::error::Error;
use crate::IEngine;
pub trait T... | true |
00478f0e3a9329393a776beb8745bf96aa883f78 | Rust | ksdme/launchk | /xpc-sys/src/objects/xpc_shmem.rs | UTF-8 | 2,446 | 2.671875 | 3 | [
"MIT"
] | permissive | use crate::objects::xpc_error::XPCError;
use crate::objects::xpc_object::XPCObject;
use crate::{
mach_port_t, mach_task_self_, rs_strerror, vm_address_t, vm_allocate, vm_deallocate, vm_size_t,
xpc_shmem_create,
};
use std::ffi::c_void;
use std::os::raw::c_int;
use std::ptr::null_mut;
use std::sync::Arc;
/// Wr... | true |
0366fd4b515c22b9d1dcd5a694a87534d1ddcfa3 | Rust | saks/hb_api | /octo-budget-api/src/apps/frontend_app.rs | UTF-8 | 236 | 2.609375 | 3 | [
"MIT"
] | permissive | use actix_web::{get, http::header, HttpResponse, Result};
#[get("/")]
pub async fn index() -> Result<HttpResponse> {
Ok(HttpResponse::PermanentRedirect()
.header(header::LOCATION, "/public/index.html")
.finish())
}
| true |
2812711c026f3fcde787004d0ecb492e91891dde | Rust | nphyx/scrapsrl | /src/system/input/player.rs | UTF-8 | 2,814 | 2.625 | 3 | [] | no_license | use crate::component::{Cursor, Direction, MovePlan, Orientation, Player, Pos, Region};
use crate::resource::{GameState, UserInput};
use specs::{Entities, Join, Read, ReadStorage, System, Write, WriteStorage};
use tcod::input::Key;
use tcod::input::KeyCode::*;
use super::movement_util::get_movement;
/// handle input t... | true |
333b612da9fba6a510a8ea032b56bc87acc92efa | Rust | avhz/QuantMath | /src/data/bumptime.rs | UTF-8 | 880 | 3.28125 | 3 | [
"MIT"
] | permissive | use dates::Date;
/// Bump that defines all the supported bumps to the spot date
pub struct BumpTime {
spot_date: Date,
spot_dynamics: SpotDynamics,
}
impl BumpTime {
pub fn new(spot_date: Date, spot_dynamics: SpotDynamics) -> BumpTime {
BumpTime {
spot_date: spot_date,
spot... | true |
983da4e09a7ce8decbe8b0380601718a3c480690 | Rust | speederking07/LZW_with_universal_coder | /src/dictionary.rs | UTF-8 | 3,132 | 3.59375 | 4 | [] | no_license | use std::ops::{Index, IndexMut};
#[derive(Debug)]
pub struct Dictionary {
words: Vec<Vec<u8>>,
tree: WordsTree
}
impl Index<usize> for Dictionary {
type Output = Vec<u8>;
fn index(&self, index: usize) -> &Self::Output {
return &self.words[index];
}
}
impl IndexMut<usize> for Dictionary {... | true |
b1b3d2945529dfedfb46c289061273b43dae5572 | Rust | cassiemeharry/pf2e-csheet | /pf2e-csheet-shared/src/calc.rs | UTF-8 | 18,942 | 2.890625 | 3 | [] | no_license | #[cfg(test)]
use proptest::prelude::*;
#[cfg(test)]
use proptest_derive::Arbitrary;
use serde::{Deserialize, Serialize};
use smallvec::SmallVec;
use smartstring::alias::String;
use std::{fmt, str::FromStr};
use thiserror::Error;
use crate::{
bonuses::{Bonus, Modifier, Penalty},
character::Character,
choice... | true |
6bc87acb6bd315bf80c39fa1be64999e89894729 | Rust | wasmerio/cranelift | /cranelift-codegen/src/dce.rs | UTF-8 | 2,407 | 2.859375 | 3 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | //! A Dead-Code Elimination (DCE) pass.
//!
//! Dead code here means instructions that have no side effects and have no
//! result values used by other instructions.
use crate::cursor::{Cursor, FuncCursor};
use crate::dominator_tree::DominatorTree;
use crate::entity::EntityRef;
use crate::ir::instructions::Instruction... | true |
6b0655e515543ab777f79fd73c939411c9caa736 | Rust | cryptopossum/gp-v2-services | /solver/src/settlement_submission/retry.rs | UTF-8 | 3,534 | 2.78125 | 3 | [] | no_license | use super::EncodedSettlement;
use anyhow::Result;
use contracts::GPv2Settlement;
use ethcontract::{
dyns::DynMethodBuilder,
errors::{ExecutionError, MethodError},
jsonrpc::types::Error as RpcError,
transaction::{confirm::ConfirmParams, ResolveCondition},
web3::error::Error as Web3Error,
GasPrice... | true |
362dcd6e537e4ae742a72c5967d558f21cd7881f | Rust | michaelfairley/adventofcode2016 | /src/bin/13.rs | UTF-8 | 1,147 | 2.984375 | 3 | [] | no_license | use std::collections::{HashSet,VecDeque};
// const INPUT: u32 = 10;
// const GOAL: (u32, u32) = (7, 4);
const INPUT: u32 = 1364;
const GOAL: (u32, u32) = (31, 39);
fn open(coords: (u32, u32)) -> bool {
let (x, y) = coords;
(x*x + 3*x + 2*x*y + y + y*y + INPUT).count_ones() % 2 == 0
}
fn main() {
let mut pendi... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.