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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
5f52d7d74c484bca0c423027520198b295866c0c | Rust | livioribeiro/project-euler | /rust/src/bin/p004.rs | UTF-8 | 3,346 | 4.125 | 4 | [
"MIT"
] | permissive | //! A palindromic number reads the same both ways. The largest palindrome made from the product of
//! two 2-digit numbers is 9009 = 91 × 99.
//!
//! Find the largest palindrome made from the product of two 3-digit numbers.
fn main() {
let mut largest = 0;
let mut largest_factor1 = 0;
let mut largest_facto... | true |
661cfb60fa388cd4f01b0d8d251226c32b2418fa | Rust | gamache/advent2018 | /advent11/src/main.rs | UTF-8 | 3,990 | 3.421875 | 3 | [] | no_license | use std::io::Error;
use std::fs::File;
use std::io::prelude::*;
use std::collections::HashMap;
fn read_input(filename: &str) -> Result<String, Error> {
let mut input = String::new();
File::open(filename)?.read_to_string(&mut input)?;
return Ok(input);
}
fn main() {
match read_input("input.txt") {
Ok(input... | true |
0bd4bd71ef549d31f36bf4d7b038c184b6617df6 | Rust | ChangeCaps/frame-factor | /src/networking/network_payload.rs | UTF-8 | 1,923 | 2.828125 | 3 | [] | no_license | use super::*;
use bevy::{prelude::*, reflect::Uuid};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
/// A payload sent through the network, supposed to be deserialized on arrival.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct NetworkPayload {
pub uuid: Uuid,
pub data: Vec<u8>,... | true |
4e1298d0a3d22fe5bdc78c99e23a3ac0ef01c754 | Rust | krivchun/fluence | /backend-sdk/crates/main/src/logger/mod.rs | UTF-8 | 5,708 | 3.140625 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright 2018 Fluence Labs Limited
*
* 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 a... | true |
b2b96b7bc9a11e9ffcaf982dc21935a325909d21 | Rust | AlecsFerra/ThatLang | /src/execution/memory.rs | UTF-8 | 1,436 | 3.265625 | 3 | [] | no_license | use std::collections::HashMap;
use crate::execution::value::Value;
pub struct Memory {
memory_frame: Vec<HashMap<String, Value>>
}
impl Memory {
pub fn new() -> Self {
Self {
memory_frame: vec![HashMap::new()]
}
}
pub fn create_frame(&mut self) {
self.memory_frame... | true |
19dd0abd50cd767feec8dc5c86437051940caf11 | Rust | baysmith/cpu-time | /src/windows.rs | UTF-8 | 5,296 | 2.9375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::marker::PhantomData;
use std::rc::Rc;
use std::time::Duration;
use winapi::shared::minwindef::FILETIME;
use winapi::um::processthreadsapi::OpenProcess;
use winapi::um::processthreadsapi::{GetCurrentProcess, GetCurrentThread};
use winapi::um::processthreadsapi::{GetProcessTimes, GetThreadTimes};
use winapi::um... | true |
dbc4d516037c4913969a90817c4f704d2b2dd7f8 | Rust | szhongren/crafting-interpreter | /src/lox/parser.rs | UTF-8 | 19,601 | 3.28125 | 3 | [] | no_license | use std::cell::{Cell, RefCell};
use super::{stmt::Stmt, token_type::TokenType};
use super::{expr::Expr, token::Literal, token::Token};
pub struct Parser {
tokens: RefCell<Vec<Token>>,
current: Cell<usize>,
}
impl Parser {
pub fn new(tokens: Vec<Token>) -> Self {
Self {
tokens: RefCel... | true |
f7ce65dce813da09f7e5f732ca836b7d41872bad | Rust | gwadej/quikdecision-web | /src/lib.rs | UTF-8 | 3,628 | 2.625 | 3 | [
"MIT"
] | permissive | extern crate hyper;
extern crate quikdecision;
#[macro_use]
extern crate serde_json;
extern crate percent_encoding;
use eyre::eyre;
use std::collections::HashMap;
use hyper::{Body, Response, StatusCode};
use percent_encoding::percent_decode;
use quikdecision::{Command, Decision, Decider, Result};
pub fn process_com... | true |
6a70834ebdfd5ddcb841371d11946e3739b179eb | Rust | frankhart2018/rust-learn | /ch-17-object-oriented-programming-features-of-rust/blog/src/main.rs | UTF-8 | 1,234 | 3.734375 | 4 | [] | no_license | use blog::Post;
fn main() {
// State pattern is an OOP pattern, the crux of this is that
// a value has some internal state which is represented by a
// set of state objects and the value's behaviour changes
// based on the internal state
// Each state object is responsible for its own behaviour ... | true |
d25ad06ec9275f4a7ce10af3082e3fc7a8081640 | Rust | Impally/ProjectEuler | /Problem2/src/main.rs | UTF-8 | 505 | 3.59375 | 4 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
fn main(){
//Find the sum of all even Fibonacci numbers below 4 million
let mut a = 1;
let mut b = 1;
while b < 4000000 || b%2 != 0 {
b += a;
a = b - a;
}
let answer = (a - 1) / 2;
let mut file = File::create("results.txt").expect... | true |
7ee15aa1897a767c1f80bea416818799a4aec753 | Rust | stulentsev/russianaicup | /CodeSide/model/src/mine.rs | UTF-8 | 588 | 2.625 | 3 | [] | no_license | use crate::*;
#[derive(Clone, Debug, trans::Trans)]
pub struct Mine {
pub player_id: i32,
pub position: Vec2F64,
pub size: Vec2F64,
pub state: MineState,
pub timer: Option<f64>,
pub trigger_radius: f64,
pub explosion_params: ExplosionParams,
}
impl Mine {
pub fn explosion_bounding_box(&... | true |
17a9d5979dbe296479840bac84e3052aa072a5d6 | Rust | fdumontmd/adventofcode | /2018/day-01/src/main.rs | UTF-8 | 721 | 3.125 | 3 | [] | no_license | use std::collections::HashSet;
use std::error::Error;
use std::io::BufRead;
use aoc_utils::get_input;
fn parse_input() -> Result<Vec<i32>, Box<dyn Error>> {
let mut v = Vec::new();
for line in get_input().lines() {
let line = line?;
v.push(line.parse()?);
}
Ok(v)
}
fn main() -> Result<... | true |
294a0164314d42a3601b42078183cab7496f7e81 | Rust | venkatarun95/audio_ct | /src/audio.rs | UTF-8 | 11,419 | 2.796875 | 3 | [] | no_license | use crate::config::Config;
use crate::test::InputSampleStream;
use failure::Error;
use num::{Complex, Zero};
use portaudio as pa;
use std::sync::mpsc::{Receiver, Sender};
const CHANNELS: i32 = 1;
const FRAMES: u32 = 256;
const INTERLEAVED: bool = true;
fn run<'c, T>(
mut modulator: Modulate<'c, T>,
rx_sender... | true |
6fcce99866cf4e501cfccffd06b8cd6794025bb3 | Rust | arcade/rust-docset | /src/docset.rs | UTF-8 | 1,711 | 2.734375 | 3 | [] | no_license | #[crate_id="docset#0.1"];
#[crate_type = "lib"];
extern mod sqlite3;
use std::fmt;
use sqlite3::types::SQLITE_DONE;
use sqlite3::Database;
pub struct Docset {
priv path: Path,
priv database: Database
}
pub struct DocsetItem {
id: int,
name: ~str,
category: ~str,
path: Path
}
impl Docset {
... | true |
40f81c466d9b5a5948c65aaa3aa8bfe18e891e0a | Rust | davidjrichardson/aoc2020 | /src/days/day_4.rs | UTF-8 | 8,159 | 2.984375 | 3 | [] | no_license | use crate::days::Challenge;
use regex::Regex;
use std::{fs, path::Path, str::FromStr};
#[derive(Debug)]
enum EyeColour {
Amber,
Blue,
Brown,
Grey,
Green,
Hazel,
Other,
}
impl FromStr for EyeColour {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match... | true |
700e0422c7d345085c2db075f1472c39857915dd | Rust | jsmall53/lineup_builder_rs | /src/main.rs | UTF-8 | 2,403 | 2.59375 | 3 | [] | no_license | #![allow(dead_code)]
#![allow(unused_imports)]
extern crate csv;
extern crate serde;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate clap;
use std::error::Error;
use std::process;
use clap::{ App, Arg, ArgMatches };
use builder::builder::{ Builder, Lineup };
fn run(matches: ArgMatches) -> Result<Ve... | true |
56b1004eaa9cdf44e0b90d58eaa7c30fa646ed63 | Rust | dalalsunil1986/rust_os | /src/smp/mod.rs | UTF-8 | 3,234 | 2.875 | 3 | [
"MIT"
] | permissive | //! Symmetric multiprocessing synchronization
use alloc::vec::Vec;
use core::fmt;
use core::sync::atomic::{AtomicU64, AtomicU8, Ordering};
use spin::Mutex;
use x86_64::VirtAddr;
use crate::driver::acpi;
use crate::driver::ioapic;
use crate::memory;
pub fn current_processor_id() -> ProcessorId {
if ioapic::is_ena... | true |
474c113054e7203e09c30571f70948d517185a69 | Rust | ordovicia/scholar | /src/bin/config.rs | UTF-8 | 895 | 3.015625 | 3 | [] | no_license | use clap::ArgMatches;
#[derive(Clone)]
pub struct Config {
pub max_result_count: Option<u32>,
pub recursive_depth: u32,
pub output_format: OutputFormat,
pub verbose: bool,
}
#[derive(Clone)]
pub enum OutputFormat {
HumanReadable,
Json,
}
impl Config {
pub fn new(matches: &ArgMatches) -> S... | true |
2eaaf4e6566b35ac56eba9d229197c4e9db5cd36 | Rust | rick68/rust-trace | /libcore/intrinsics/fmaf64.rs | UTF-8 | 350 | 2.71875 | 3 | [
"MIT"
] | permissive | #![feature(core, core_intrinsics)]
extern crate core;
#[cfg(test)]
mod tests {
use core::intrinsics::fmaf64;
// pub fn fmaf64(a: f64, b: f64, c: f64) -> f64;
#[test]
fn fmaf64_test1() {
let a: f64 = 68.0;
let b: f64 = 100.0;
let c: f64 = 1.0;
let result: f64 = unsafe { fmaf64(a, b, c) };
assert... | true |
0766b2bf653db6d0b35b76ee2d088dfb108fbb64 | Rust | tremor-rs/tremor-runtime | /src/connectors/impls/crononome.rs | UTF-8 | 7,970 | 2.8125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // Copyright 2021, The Tremor 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 t... | true |
aa3545fedb303631f237705d81a6636eed125b18 | Rust | lunjon/dotfiles | /src/files/mod.rs | UTF-8 | 788 | 2.796875 | 3 | [] | no_license | use anyhow::Result;
use data_encoding::HEXLOWER;
use ring::digest::{Context, SHA256};
use std::fs;
use std::io::Read;
use std::path::Path;
#[cfg(test)]
mod tests;
pub fn digest(data: &[u8]) -> Result<String> {
let mut context = Context::new(&SHA256);
context.update(data);
let digest = context.finish();
... | true |
336f2e38d5ee7223584251d45031d3d6dc1390d9 | Rust | veaba/learn-rust | /src/impl/impl.rs | UTF-8 | 251 | 3.4375 | 3 | [] | no_license | struct Style {
width: u32,
height: u32,
}
impl Style {
fn area(&self) -> u32 {
self.width * self.height
}
}
fn main() {
let rect = Style {
width: 30,
height: 90,
};
println!("{:?}", rect.area())
}
| true |
dc8f72f28270170a939b4d0ed39e1ed90044a05b | Rust | iamsix/leetcode | /3.substringwithoutrepeating.0.rs | UTF-8 | 720 | 3.15625 | 3 | [] | no_license | use std::collections::HashMap;
impl Solution {
pub fn length_of_longest_substring(s: String) -> i32 {
let mut ln = 0;
let mut chrs = HashMap::new();
let mut start = 0;
let mut end = 0;
for (i, c) in s.chars().enumerate() {
if !chrs.contains_key(&c) {
... | true |
fb23e587047a3563c51d6fc4b9d220098159fe42 | Rust | azerupi/aoc-2019 | /src/bin/day2-1.rs | UTF-8 | 483 | 2.90625 | 3 | [] | no_license | use std::io::{self, Read};
use aoc_2019::computer::Computer;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut input = String::new();
io::stdin().read_to_string(&mut input)?;
let mut values: Vec<i64> = input.split(',')
.map(|i| i.trim().parse().unwrap())
.collect();
values... | true |
2b6a1b9881bc846b0f2cced99d21bf8d11843a16 | Rust | SilvestrePerret/adventofcode-2020 | /day-14/part-2/enizor.rs | UTF-8 | 2,947 | 3.3125 | 3 | [
"MIT"
] | permissive | #![feature(destructuring_assignment)]
use std::time::Instant;
use std::{collections::HashMap, env::args};
fn main() {
let now = Instant::now();
let output = run(&args().nth(1).expect("Please provide an input"));
let elapsed = now.elapsed();
println!("_duration:{}", elapsed.as_secs_f64() * 1000.);
p... | true |
4ea8896307b4f261e3376c91d293321080bb7bb7 | Rust | echosun1996/LeetCodeFighting | /数组/1470.重新排列数组.rs | UTF-8 | 530 | 3.765625 | 4 | [] | no_license | /// 解法一
/// 循环数组的一半,取第i和i+n位元素
struct Solution {
}
impl Solution {
pub fn shuffle(nums: Vec<i32>, n: i32) -> Vec<i32> {
let mut result = vec![0;nums.len()];
for i in 0 .. nums.len()/2 {
result[i*2] = nums[i];
result[i*2+1] = nums[i + n as usize];
}
result
... | true |
d7e6f0020b673993c6219eb32399ad19d65a88b2 | Rust | mythmon/advent-of-code | /year2019/src/day14/mod.rs | UTF-8 | 6,502 | 2.8125 | 3 | [
"MIT"
] | permissive | use advent_lib::{
cases::{/* ExpectedValue, */ GenericPuzzleCase, Puzzle, PuzzleCase, PuzzleRunner},
helpers::StringAdventExt,
};
use std::{cmp::Ordering, collections::HashMap, iter::Iterator};
pub fn get_puzzles() -> Vec<Box<dyn Puzzle>> {
vec![Box::new(Part1), Box::new(Part2)]
}
#[derive(Debug)]
pub str... | true |
dad6e961f53fb36d4457387ca3b94dd1bca8fa89 | Rust | chnnxyz/klabnik-rust | /04_crates/restaurant/src/lib.rs | UTF-8 | 3,417 | 3.71875 | 4 | [] | no_license | // The mod keyword defines a module and its name
mod front_of_house {
// The hosting and serving mods are submodules
pub mod hosting {
//modules can contain structs, enums, constants, traits or functions
pub fn add_to_waitlist() {}
fn seat_at_table() {}
}
pub mod serving {
... | true |
da36d95c228b72a4ce2d7023e7e10ea65153cdb0 | Rust | yarlett/bit-codes | /examples/make_bit_code.rs | UTF-8 | 499 | 2.765625 | 3 | [] | no_license | extern crate bit_codes;
fn main() {
let string = "Supercalifragilisticexpialidocious";
let downcase = true;
let ngram_lengths = vec![3, 4, 5, 6];
let num_bits = 256;
let num_features = 500;
let encoding_options = bit_codes::encoding_options::EncodingOptions::new(
downcase,
ngram... | true |
a148903ca72b2f9f7551cbb35ddf96781757a750 | Rust | Woprok/woprok_discord_bot | /src/src_bot/bot/bot_utils/bot_personality.rs | UTF-8 | 220 | 2.59375 | 3 | [
"MIT"
] | permissive | pub const BOT_NAME:&str = "Woprok";
pub const BOT_LUCKY_NUMBER:u32 = 6_7_1996;
pub fn present_yourself()
{
println!("I am Rust Bot a.k.a {}. Smart and Edgy! My lucky number is: {} :)", BOT_NAME, BOT_LUCKY_NUMBER);
} | true |
c33e1b9d4801b192bec17f0e5d3e92260bf4f1ec | Rust | Trivernis/vented | /src/event/tests.rs | UTF-8 | 1,285 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | /*
* vented asynchronous event based tcp server
* Copyright (C) 2020 trivernis
* See LICENSE for more information
*/
use serde::{Deserialize, Serialize};
use crate::event::Event;
#[derive(PartialEq, Serialize, Deserialize, Clone, Debug)]
struct SimplePayload {
string: String,
number: u32,
float: f32,... | true |
5e3b977583ceeb9befa07da0bcefb39473abe6a8 | Rust | slaterb1/simple-es | /src/search.rs | UTF-8 | 11,974 | 2.53125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use reqwest;
use reqwest::StatusCode;
use serde_json::Value;
use serde::Deserialize;
use crate::client::{EsClient, IndexPattern};
use crate::utils::serialize_response;
use crate::errors::ESGenericFail;
#[derive(Deserialize, Debug, PartialEq)]
pub struct EsSearchResponse<T> {
took: u16,
timed_out: bool,
#[... | true |
20ba201a0f7d12c814b7ddd4f696cf53a43b5f36 | Rust | pgcrooks/advent_2020 | /src/day_6.rs | UTF-8 | 1,544 | 3.578125 | 4 | [] | no_license | use std::error::Error;
use std::fs;
use advent::Config;
fn count_newlines(s: &str) -> usize {
s.as_bytes().iter().filter(|&&c| c == b'\n').count() + 1
}
fn count_group_answers(group: &str) -> usize {
let group_size = count_newlines(group);
// Remove newlines from the char list
let mut questions: Vec... | true |
a1ae3efffa69608740cb1d536909433f02dcd155 | Rust | manuel-rhdt/mlayout | /src/mathmlparser/operator.rs | UTF-8 | 8,457 | 2.84375 | 3 | [
"MIT"
] | permissive | use crate::types::{
Atom, GeneralizedFraction, Length, MathExpression, MathItem, Operator, OverUnder,
StretchConstraints,
};
use super::operator_dict;
use super::{FromXmlAttribute, ParseContext};
bitflags! {
pub struct Flags: u8 {
const SYMMETRIC = 0b00000001;
const FENCE ... | true |
5612765fec602849ae28bbec9695171fee435323 | Rust | anselanza/nannou | /src/app.rs | UTF-8 | 12,671 | 2.84375 | 3 | [
"MIT"
] | permissive | use audio;
use audio::cpal;
use find_folder;
use glium::glutin;
use state;
use std;
use std::cell::{Cell, RefCell};
use std::collections::HashMap;
use std::marker::PhantomData;
use std::path::PathBuf;
use std::sync::{mpsc, Arc};
use std::thread;
use std::time::Duration;
use window::{self, Window};
use ui;
/// An **App... | true |
bdca4634036cea8c192c9a85cc5d811d68de5743 | Rust | nilsso/challenge-solutions | /exercism/rust/two-bucket/src/lib.rs | UTF-8 | 1,912 | 3.234375 | 3 | [] | no_license | #[derive(PartialEq, Eq, Debug)]
pub enum Bucket {
One,
Two,
}
#[derive(PartialEq, Eq, Debug)]
pub struct BucketStats {
pub moves: u8,
pub goal_bucket: Bucket,
pub other_bucket: u8,
}
pub fn solve(c1: u8, c2: u8, goal: u8, start_bucket: &Bucket) -> BucketStats {
if start_bucket == &Bucket::Two ... | true |
cf45a273bea2b436f1401e2186bcbb497190d7b3 | Rust | seanwallawalla-forks/nushell | /crates/nu-command/src/commands/strings/str_/substring.rs | UTF-8 | 11,009 | 2.734375 | 3 | [
"MIT"
] | permissive | use crate::prelude::*;
use nu_engine::WholeStreamCommand;
use nu_errors::ShellError;
use nu_protocol::ShellTypeName;
use nu_protocol::{
ColumnPath, Primitive, ReturnSuccess, Signature, SyntaxShape, UntaggedValue, Value,
};
use nu_source::Tag;
use nu_value_ext::{as_string, ValueExt};
use std::cmp::Ordering;
use std... | true |
00f3ac77d8d587b0b1343fe34a04cf3fd54b8b28 | Rust | autarch/edgedb-rust | /edgedb-protocol/src/model/json.rs | UTF-8 | 730 | 3.328125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | /// A newtype for JSON received from the database
#[derive(Debug, Clone)]
pub struct Json(String);
impl Json {
pub(crate) fn _new_unchecked(value: String) -> Json {
Json(value)
}
/// Create JSON value without checking the contents
///
/// This is used to construct values from the data received from the... | true |
36d55c31a47361de8f9e1318e126d20c6f07be9d | Rust | AlisCode/AdventOfCode2017 | /day16_parser/src/lib.rs | UTF-8 | 959 | 2.625 | 3 | [] | no_license | #[macro_use]
extern crate nom;
use std::str;
use nom::{alpha, digit};
named!(
number<u32>,
map_res!(map_res!(digit, str::from_utf8), str::parse)
);
named!(
spin_infos<usize>,
do_parse!(tag!("s") >> size: number >> (size as usize))
);
named!(
exchange_infos<(usize, usize)>,
do_parse!(
... | true |
4b590a60e9092b2770274abc6f1183955e7736d3 | Rust | substation-beta/ssb_book | /build.rs | UTF-8 | 1,251 | 2.828125 | 3 | [
"CC-BY-4.0"
] | permissive | use mdbook::MDBook;
use std::{
fs::{copy, create_dir_all, read_dir, FileType},
io::Result
};
fn main() {
// Working directory
let build_dir = env!("CARGO_MANIFEST_DIR").to_owned();
// Compile book
MDBook::load(build_dir.clone()).expect("Couldn't load book descriptor!")
.build().expect("... | true |
e781d04b9e96cf6a2b20e8b22c99cbc334c7a847 | Rust | MartinKavik/libredu | /ulak/src/models/others.rs | UTF-8 | 2,728 | 2.59375 | 3 | [] | no_license | use chrono::NaiveDateTime;
use crate::schema::*;
use crate::models::activity::Activities;
use crate::models::user::User;
#[derive(Deserialize, Serialize, Debug, Queryable, PartialEq, AsExpression, Clone)]
pub struct Class{
pub id: i32,
pub kademe: i16,
pub sube: String,
pub school: i32,
pub teacher... | true |
39a559e819f8487c720b52d90c751c39f55ea161 | Rust | cathay4t/libnm-rs | /src/ip_route.rs | UTF-8 | 10,031 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | // This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use glib;
use glib::translate::*;
use glib::GString;
use nm_sys;
#[cfg(any(feature = "v1_8", feature = "dox"))]
use std::mem;
use std::ptr;
glib_wrapper! {
#[derive(Debug, Parti... | true |
24e43d35ad37dc6481175ddfbfc572e5643dc891 | Rust | fluencelabs/llamadb | /src/byteutils.rs | UTF-8 | 8,445 | 3 | 3 | [
"MIT"
] | permissive | #![allow(dead_code)]
pub fn read_u16_le(buf: &[u8]) -> u16 {
assert_eq!(buf.len(), 2);
buf.iter()
.enumerate()
.fold(0, |prev, (i, v)| prev | ((*v as u16) << (i * 8)))
}
pub fn read_u32_le(buf: &[u8]) -> u32 {
assert_eq!(buf.len(), 4);
buf.iter()
.enumerate()
.fold(0,... | true |
e1b7d07457347f9816d03df781ffc6918b0db371 | Rust | walteralleyz/estudos | /Rust/users.rs | UTF-8 | 2,511 | 3.65625 | 4 | [] | no_license | use std::io::{Write, BufReader, BufRead, Error};
use std::io;
use std::fs::File;
use std::fmt;
struct User {
name: String,
age: u8,
email: String,
city: String,
country: String,
postal_code: u32,
}
impl fmt::Display for User {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
... | true |
8c71690042189caa1f6c585c28351d5688cdcf9d | Rust | Matthias-Fauconneau/iced | /graphics/src/widget/canvas/geometry.rs | UTF-8 | 837 | 3.53125 | 4 | [
"MIT"
] | permissive | use crate::Primitive;
/// A bunch of shapes that can be drawn.
///
/// [`Geometry`] can be easily generated with a [`Frame`] or stored in a
/// [`Cache`].
///
/// [`Geometry`]: struct.Geometry.html
/// [`Frame`]: struct.Frame.html
/// [`Cache`]: struct.Cache.html
#[derive(Debug, Clone)]
pub struct Geometry(Primitive);... | true |
73f50f93e046c5b0e6b603e7e6a1fb1121a45a1f | Rust | NivenT/REnforce | /src/environment/finite.rs | UTF-8 | 788 | 3.4375 | 3 | [] | no_license | use rand::{Rng, thread_rng};
use environment::{Space, FiniteSpace};
/// Finite
///
/// Represents a Space with finitely many elements, {0, 1, 2, ..., size-1}
#[derive(Debug, Clone, Copy)]
pub struct Finite {
/// The number of elements in the space
size: u32,
}
impl Space for Finite {
type Element = u32;
fn samp... | true |
0e80b98ee9fc38b310cb911ca11faaa605be35da | Rust | Pluriscient/rust-sudoku-solver | /src/sudokutwo/entry_num.rs | UTF-8 | 3,766 | 3.578125 | 4 | [] | no_license | use std::convert::TryInto;
pub type EntryNum = u16;
pub const ONE: EntryNum = 0b1;
pub const TWO: EntryNum = 0b10;
pub const THREE: EntryNum = 0b100;
pub const FOUR: EntryNum = 0b1000;
pub const FIVE: EntryNum = 0b10000;
pub const SIX: EntryNum = 0b100000;
pub const SEVEN: EntryNum = 0b1000000;
pub const EIGHT: Entry... | true |
3a69fbcd7519488f0ac8460f43d5782eb2c444bb | Rust | Azure/azure-sdk-for-rust | /services/svc/datalakeanalytics/src/package_job_2016_11/models.rs | UTF-8 | 44,511 | 2.765625 | 3 | [
"LicenseRef-scancode-generic-cla",
"MIT",
"LGPL-2.1-or-later"
] | permissive | #![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::de::{value, Deserializer, IntoDeserializer};
use serde::{Deserialize, Serialize, Serializer};
use std::str::FromStr;
#[doc = "Data Lake Analytics Job Parameters base class for build and submit."]
#[derive(Clone, Debug, PartialEq, Serialize, Deserializ... | true |
437a7d23bf81da8ee1c338fc4e3fe4c95f390dd3 | Rust | mathieu-lemay/aoc-2020 | /d03/src/main.rs | UTF-8 | 1,044 | 3.15625 | 3 | [
"MIT"
] | permissive | use std::fmt::Display;
use std::time::Instant;
use aoc_2020::get_input;
fn is_tree(row: &str, row_num: usize, xmult: usize) -> bool {
row.chars().nth((row_num * xmult) % row.len()).unwrap() == '#'
}
fn solve(input: &[String]) -> (impl Display, impl Display) {
let number1 = input
.iter()
.enum... | true |
a976188c93fd8b630499d0c4f166859ea18471ea | Rust | ReinierMaas/PathTracer | /src/scene.rs | UTF-8 | 6,003 | 2.703125 | 3 | [] | no_license | extern crate cgmath;
use self::cgmath::{Vector3, Point3};
use std::io;
use std::path::Path;
use std::mem;
use bvh::BVH;
use std::f32::consts::FRAC_1_PI;
extern crate memmap;
use self::memmap::*;
use primitive::Primitive;
use primitive::sphere::Sphere;
use primitive::triangle::Triangle;
use material;
use material::Mate... | true |
16e6f56252dabf63942c1028c4a767b4c51dcf81 | Rust | quebin31/ant-system | /src/system.rs | UTF-8 | 6,678 | 2.796875 | 3 | [] | no_license | use crate::utils::{ToCharIndex, ToDisplayPath};
use anyhow::Error;
use ndarray::{Array2, Ix2, ShapeBuilder};
use rand::{thread_rng, Rng};
use std::io::Write;
fn init_pheromone_matrix<S>(shape: S, value: f64) -> Array2<f64>
where
S: ShapeBuilder<Dim = Ix2>,
{
Array2::from_shape_fn(shape, |(i, j)| if i == j { 0.... | true |
b91fe010d91cb8e9e3e067fad3501473524373ca | Rust | Agile-Llama/Rust-Stuff | /1-GuessGame/src/main.rs | UTF-8 | 1,677 | 4.03125 | 4 | [] | no_license | extern crate rand;
use rand::Rng;
use std::io;
use std::cmp::Ordering;
fn main() {
let random_number = rand::thread_rng().gen_range(1, 100);
let mut correct = false;
let mut guesses = 0;
while correct == false {
let mut input = String::new();
println!("Guess the number");
io:... | true |
bab09e7b9ab450f575a6f6c7c31f7add656ce9d3 | Rust | Muqito/ws-lite-use | /server/src/connection.rs | UTF-8 | 1,315 | 2.734375 | 3 | [] | no_license | use crate::messages::Messages;
use crate::{TcpStream, WsError};
use futures_lite::AsyncWriteExt;
use ws_lite::message::{Message, WriteMessage};
#[derive(Debug)]
pub struct TcpStreamNT {
tcp_stream: TcpStream,
}
impl TcpStreamNT {
pub async fn send<'a, I>(&mut self, data: I) -> Result<(), WsError>
where
... | true |
1112887f24b6d9f575349c47c401fd376e5f10a6 | Rust | guillaume-be/rust-tokenizers | /main/tests/test_deberta_cased.rs | UTF-8 | 10,238 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | mod test_utils;
use rust_tokenizers::tokenizer::{DeBERTaTokenizer, Tokenizer, TruncationStrategy};
use rust_tokenizers::{Offset, TokenizedInput};
use test_utils::download_file_to_cache;
#[test]
fn test_deberta_tokenization() -> anyhow::Result<()> {
let vocab_path = download_file_to_cache(
"https://hugging... | true |
1cdd33ccaa98b82a3f4adc9e4483dce5de04c63b | Rust | qm3ster/Notcraft | /src/engine/resources/mod.rs | UTF-8 | 943 | 2.578125 | 3 | [
"MIT"
] | permissive | use cgmath::{Deg, Matrix3, Matrix4, PerspectiveFov, Point3, Vector2, Vector3};
use collision::Ray3;
use std::time::Duration;
#[derive(Copy, Clone, Debug, PartialEq, Default)]
pub struct CursorPos {
pub x: f64,
pub y: f64,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Default)]
pub struct StopGameLoop(pu... | true |
444a29e425cd8887eae96af887f9d32255913ff3 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/ash/src/extensions/ext/debug_marker.rs | UTF-8 | 2,183 | 2.515625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use
crate
:
:
prelude
:
:
*
;
use
crate
:
:
vk
;
use
crate
:
:
{
Device
Instance
}
;
use
std
:
:
ffi
:
:
CStr
;
use
std
:
:
mem
;
#
[
derive
(
Clone
)
]
pub
struct
DebugMarker
{
handle
:
vk
:
:
Device
fp
:
vk
:
:
ExtDebugMarkerFn
}
impl
DebugMarker
{
pub
fn
new
(
instance
:
&
Instance
device
:
&
Device
)
-
>
Self
{
let... | true |
7b345a62e38342ed32ffb48367e75a77759218e9 | Rust | niladic/egui | /egui/src/widgets/plot/items.rs | UTF-8 | 17,112 | 3.359375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Contains items that can be added to a plot.
use std::ops::RangeInclusive;
use super::transform::{Bounds, ScreenTransform};
use crate::*;
/// A value in the value-space of the plot.
///
/// Uses f64 for improved accuracy to enable plotting
/// large values (e.g. unix time on x axis).
#[derive(Clone, Copy, Debug, ... | true |
4f7227cba203dfc0265168026b18fb75bad5332c | Rust | patrickkerrigan/rust-cnc | /src/main.rs | UTF-8 | 904 | 2.984375 | 3 | [
"BSD-3-Clause"
] | permissive | use rust_cnc::{process};
use std::process::exit;
use std::env::Args;
use std::fs::read_to_string;
use std::io::Error;
pub struct Config {
pub dxf_file: String
}
impl Config {
pub fn new(mut args: Args) -> Result<Config, &'static str> {
args.next();
let dxf_file = match args.next() {
... | true |
479ea1c1206fd3b7ae74ea1dc66f02e723659ee2 | Rust | sharksforarms/deku | /tests/test_attributes/test_padding/mod.rs | UTF-8 | 1,465 | 2.796875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use deku::prelude::*;
use std::convert::{TryFrom, TryInto};
mod test_pad_bits_after;
mod test_pad_bits_before;
mod test_pad_bytes_after;
mod test_pad_bytes_before;
#[test]
#[allow(clippy::identity_op)]
fn test_pad_bits_before_and_pad_bytes_before() {
#[derive(PartialEq, Debug, DekuRead, DekuWrite)]
struct Tes... | true |
12c24b116a5d4cebe7255b86299c6c3c6fd403d6 | Rust | Hamcha/apicurio-sync | /src/provider.rs | UTF-8 | 4,268 | 2.640625 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::fmt::{self, Display, Formatter};
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use crate::context;
use crate::error::Error;
#[async_trait]
pub trait Provider {
async fn system_info(&self, auth: &context::Auth) -> Result<SystemInfo, Error>;
async fn... | true |
33f3666300d55848e367a0d2e642f8d0d514673a | Rust | nledford/Scarlett | /src/handlers/entity.rs | UTF-8 | 2,139 | 2.765625 | 3 | [] | no_license | use actix_web::{delete, get, patch, post, web};
use deadpool_postgres::Pool;
use crate::requests::search_request::SearchRequest;
use crate::responses::api_response::ApiResponse;
use crate::schemas::entity::Entity;
use crate::types::HandlerResult;
// ALL ENTITIES *******************************************************... | true |
5b73ebc4c1c7909e01d5fa0a6dcd5d4574294593 | Rust | placrosse/kaze | /src/command_helpers.rs | UTF-8 | 726 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"BSD-2-Clause"
] | permissive | use std::process::Command;
use super::logger::Logger;
use super::error_helpers;
pub fn execute(command: &mut Command, logger: &Logger) -> Result<(), String> {
logger.println(1, &format!("Running command:\n{:?}", command));
let output = try!(error_helpers::io_result_to_result(command.output()));
let status... | true |
78d11fa8f1ad114499c221752f16a49ce51454ae | Rust | dfbrown/advent_of_code_2017 | /day22/src/main.rs | UTF-8 | 3,523 | 3.328125 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io::prelude::*;
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::iter::FromIterator;
enum State {
Infected,
Weakened,
Flagged,
}
fn get_input() -> HashSet<(isize, isize)> {
let mut f = File::open("input.txt").expe... | true |
7eef1a6577faac001a24b3c6d043087af0ef734e | Rust | RiverTethys/rust-rosetta | /src/hamming_numbers.rs | UTF-8 | 3,296 | 3.5625 | 4 | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | // Implements http://rosettacode.org/wiki/Hamming_numbers
// port of one of the scala solutions
extern crate num;
use num::bigint::BigUint;
use std::cmp::min;
use std::sync::spsc_queue::Queue;
// helper function to avoid repeating
// FromPrimitive::from_int(i).unwrap()
// for every BigUint creation
fn int_to_biguint(i... | true |
a1f600849f78c79ce4c99849768000954bddefb7 | Rust | piedoom/j | /src/systems/movement.rs | UTF-8 | 1,615 | 2.578125 | 3 | [] | no_license | use crate::components::{GridMovement, Movement};
use amethyst::core::Time;
use amethyst::core::{Float, Transform};
use amethyst::ecs::{Join, Read, ReadStorage, System, WriteStorage};
pub struct GridMovementSystem {}
impl Default for GridMovementSystem {
fn default() -> Self {
Self {}
}
... | true |
6990d6cff62b5b35a1afe95bcee5d78b8bb199d9 | Rust | tuplecats/hash-rings-rs | /src/test_util.rs | UTF-8 | 555 | 2.71875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::collections::hash_map::DefaultHasher;
use std::hash::{BuildHasherDefault, Hasher};
pub struct AddHasher {
sum: u64,
}
impl Hasher for AddHasher {
fn write(&mut self, bytes: &[u8]) {
for byte in bytes {
self.sum += u64::from(*byte);
}
}
fn finish(&self) -> u64 {
... | true |
6e4ca4077e7fb4d6379c0d86d796e30561b6e6fc | Rust | mexus/tokio-futures-faq | /examples/read-write-in-parallel.rs | UTF-8 | 10,212 | 3.1875 | 3 | [] | no_license | //! Пример с асинхронными параллельно работающими чтением/записью в сокет.
use futures::Future;
use std::net::SocketAddr;
use tokio::net::TcpListener;
mod server {
use futures::{Future, Stream};
use tokio::{
io::{copy, AsyncRead},
net::TcpListener,
};
/// Простенький ехо-сервер.
p... | true |
24787c92a482f9205586d1c3436e687a420885ed | Rust | kamranajabbar/ch_08_strings | /src/strings.rs | UTF-8 | 485 | 3.53125 | 4 | [] | no_license | pub fn run(){
let estr = String::new(); // Empty String
println!("Empty String : {:?}", estr);
let data = "Kamran Jabbar"; // String Literals
let s = data.to_string();
println!("String 1 : {:?}", s);
let s = String::from("initial contents"); // Create a Stri... | true |
2f5ec75b11c7a8e97f1c28e299ac1a636c4fc52a | Rust | mtimkovich/advent-of-code-2020 | /src/day4.rs | UTF-8 | 3,077 | 3.296875 | 3 | [] | no_license | use regex::Regex;
use std::collections::HashMap;
use std::collections::HashSet;
union FieldValue<'a> {
year: u32,
height: &'a str,
hcl: &'a str,
ecl: &'a str,
pid: u32,
}
fn has_required(set: &HashSet<String>) -> bool {
let required_fields = vec!["byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"... | true |
ade9d22fbdfc82816455b5f5f2371928a2bfaae7 | Rust | akofke/adventofcode2018 | /src/day4.rs | UTF-8 | 3,471 | 2.90625 | 3 | [] | no_license | extern crate chrono;
extern crate regex;
use self::chrono::prelude::*;
use self::regex::Regex;
use std::collections::HashMap;
#[derive(Debug)]
enum ReportType {
BeginsShift(u32),
FallsAsleep,
WakesUp,
}
#[derive(Debug)]
struct GuardReport {
timestamp: NaiveDateTime,
report_type: ReportType,
}
fn... | true |
e3d33fa561b3500a9ca90e36b79d49d221bb9c48 | Rust | dncc/pyqpick | /qpickwrapper/src/lib.rs | UTF-8 | 3,353 | 2.765625 | 3 | [
"MIT"
] | permissive | #![crate_type = "dylib"]
extern crate libc;
extern crate qpick;
use std::ffi::{CStr, CString};
/// Get an immutable reference from a raw pointer
macro_rules! ref_from_ptr {
($p:ident) => (unsafe {
assert!(!$p.is_null());
&*$p
})
}
/// Get the object referenced by the raw pointer
macro_rules!... | true |
e07f998f5fe1b68f5c12969bfd185ab0eebabb2e | Rust | fengalin/media-toc | /metadata/src/duration.rs | UTF-8 | 2,259 | 3.046875 | 3 | [
"MIT"
] | permissive | use std::{
fmt,
ops::{Div, DivAssign, Mul, MulAssign},
};
// FIXME: consider moving to std::time::Duration when `div_duration` is stabilized.
#[derive(Clone, Copy, Default, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct Duration(u64);
impl Duration {
pub const fn from_nanos(nanos: u64) -> Self {
... | true |
7f1e639e01a1dbb444719311b99d22cc63a794be | Rust | iluminat23/rusdd | /src/main.rs | UTF-8 | 4,662 | 2.546875 | 3 | [] | no_license | extern crate byte_unit;
//use byte_unit::Byte;
extern crate clap;
use clap::{Arg, App};
use std::fs::OpenOptions;
use std::io;
use std::io::{BufReader, Read, Write, Seek, SeekFrom};
//use std::convert::{From, TryFrom};
const BLOCKSIZE:usize = 4096;
fn main() -> io::Result<()> {
let matches = App::new("rusdd: dd i... | true |
3b7eb48b51759fe60c38f13fd305f3d7869f070f | Rust | NikVolf/zrpc | /derive/src/codegen.rs | UTF-8 | 6,802 | 2.515625 | 3 | [] | no_license | use std::convert::TryFrom;
use proc_macro2::TokenStream;
use syn::{Result, ItemTrait, ItemImpl, ImplItem};
use quote::quote;
use crate::options::DeriveOptions;
mod c {
use syn::{
Ident, Type, Signature, Error, Result, FnArg, PatType,
Pat, PatIdent, spanned::Spanned, ReturnType
};
use std::... | true |
5cf9a559c50ea640f69ae43a3e4a267fac457869 | Rust | BrightonRust/xmas-lights | /src/main.rs | UTF-8 | 6,025 | 2.703125 | 3 | [] | no_license | #![no_main]
#![no_std]
use panic_semihosting as _; // logs messages to the host stderr; requires a debugger
// Give an *unused* interrupt to RTIC so that it can use this for scheduling
// see https://rtic.rs/dev/book/en/by-example/software_tasks.html
#[rtic::app(device = hal::pac, dispatchers = [USART1])]
mod app {
... | true |
c999891ed76e6d796a11a3d971b8ff85e1a83a59 | Rust | rcore-os/riscv-sbi | /src/hart_mask.rs | UTF-8 | 1,509 | 3.078125 | 3 | [
"LicenseRef-scancode-mulanpsl-2.0-en",
"MIT"
] | permissive | use core::mem::size_of;
extern crate alloc;
use alloc::{vec, vec::Vec};
#[derive(Debug, Clone)]
/// Hart mask for selecting harts in many extensions
pub struct HartMask {
inner: Vec<usize>,
max_hart_id: usize,
}
impl HartMask {
/// Create a new hart mask with no harts selected
pub fn none(max_hart_id... | true |
426e75e81a9b3f08ba7d643cba77ba0189e7a51c | Rust | matthieu-m/stysh | /stysh-compile/src/model/ast/interning.rs | UTF-8 | 2,246 | 3.109375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Interning.
//!
//! Test facilities to remove or add the InternId.
use std::rc;
use crate::basic::com::{self, Range};
use crate::basic::mem;
use crate::model::ast::*;
/// Resolver
#[derive(Clone)]
pub struct Resolver {
source: Vec<u8>,
interner: rc::Rc<mem::Interner>,
}
//
// Public interface of Resolv... | true |
e623acc5658266f8143f4555aae6de26a321f431 | Rust | akiles/embassy | /embassy-executor/src/arch/std.rs | UTF-8 | 2,445 | 3.078125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::marker::PhantomData;
use std::sync::{Condvar, Mutex};
use super::{raw, Spawner};
/// Single-threaded std-based executor.
pub struct Executor {
inner: raw::Executor,
not_send: PhantomData<*mut ()>,
signaler: &'static Signaler,
}
impl Executor {
/// Create a new Executor.
pub fn new() -> S... | true |
9bd3056daff9a2043d34d2c3776a09066a81f184 | Rust | gleam-lang/gleam | /compiler-core/src/bit_string.rs | UTF-8 | 9,339 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | use smol_str::SmolStr;
use crate::ast::{BitStringSegmentOption, SrcSpan};
use crate::type_::Type;
use std::sync::Arc;
//
// Public Interface
//
pub fn type_options_for_value<TypedValue>(
input_options: &[BitStringSegmentOption<TypedValue>],
) -> Result<Arc<Type>, Error>
where
TypedValue: GetLiteralValue,
{
... | true |
9d23a3031520cf6ef962038dd5713771b4b5e54f | Rust | yanns/chomp | /src/parse.rs | UTF-8 | 2,902 | 3.390625 | 3 | [] | no_license | use {Input, ParseResult};
use primitives::{IntoInner, State};
use primitives::input;
/// Simple error type returned from `parse_only`.
#[derive(Debug, Eq, PartialEq)]
pub enum ParseError<'a, I, E>
where I: 'a {
/// A parse error occurred.
Error(&'a [I], E),
/// The parser attempted to read more data than... | true |
13c4cf7a1a257b090beb7ee1744b088118021485 | Rust | bytebuddha/xi-term | /src/components/view/handler.rs | UTF-8 | 2,560 | 2.65625 | 3 | [
"MIT"
] | permissive | use crossterm::event::{ Event, KeyCode, MouseEvent, MouseButton };
use super::View;
use core::{ EventHandler, ActionHandler };
use actions::{ ViewAction, CursorAction };
use components::PromptResponse;
impl EventHandler for View {
fn handle_event(&mut self, event: Event) {
match event {
Event... | true |
69c918d1ba49e57eb87eb5bdd636eca1781da69f | Rust | rs-ipfs/rust-ipfs | /unixfs/examples/cat.rs | UTF-8 | 5,544 | 3.015625 | 3 | [
"MIT",
"Apache-2.0",
"CC-BY-4.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use cid::Cid;
use ipfs_unixfs::file::{visit::IdleFileVisit, FileReadFailed};
use std::convert::TryFrom;
use std::fmt;
use std::io::{Error as IoError, Read, Write};
use std::path::PathBuf;
fn main() {
let cid = match std::env::args().nth(1).map(Cid::try_from) {
Some(Ok(cid)) => cid,
Some(Err(e)) => ... | true |
49bb4dc08d96afb6741e09d21007ebef323718b8 | Rust | zubivan/games50-rust | /pong/src/states/startscreenstate.rs | UTF-8 | 1,119 | 2.703125 | 3 | [
"MIT"
] | permissive | use ggez::input::keyboard;
use ggez::input::keyboard::KeyCode;
use ggez::nalgebra::Point2;
use ggez::Context;
use super::countdownstate::CountdownState;
use super::utils;
use std::time::Duration;
use crate::constants::{SMALL_FONT_SIZE, VIRTUAL_WORLD_HEIGHT, VIRTUAL_WORLD_WIDTH};
use crate::traits::{State, StateWith... | true |
7a85074a72060e1f0b0ce52880c9539fc3188a94 | Rust | dcarosone/pm | /src/list.rs | UTF-8 | 1,928 | 2.625 | 3 | [] | no_license | /*
* Copyright (c) 2019 Jonathan Perkin <jonathan@perkin.org.uk>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS ... | true |
8e9d757f3122ae8b836bf32668ea0e7a1e3c123c | Rust | rinor/poldercast | /src/poldercast/cyclon.rs | UTF-8 | 2,087 | 2.78125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::{GossipsBuilder, Id, Layer, NodeProfile, Nodes, ViewBuilder};
use rand::{seq::IteratorRandom, Rng};
use std::collections::BTreeSet;
const CYCLON_MAX_VIEW_LENGTH: usize = 20;
const CYCLON_MAX_GOSSIPING_LENGTH: usize = 10;
/// this module is responsible for randomly selecting Nodes
/// to be gossiped to anot... | true |
b64d4013578697f1100f4373e5cb72d1df8b782b | Rust | Phantomical/sigset-rs | /src/lib.rs | UTF-8 | 4,212 | 2.578125 | 3 | [] | no_license | //! Bindings for `sigset_t` on linux
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg(unix)]
mod sys {
pub use libc::{sigaddset, sigdelset, sigemptyset, sigfillset, sigismember, sigset_t};
}
use core::fmt;
use core::mem::MaybeUninit;
use libc::c_int;
pub use sys::sigset_t;
pub struct SigSet {
set: sys::si... | true |
5cf6e80438aac5d02ab6a5d9f0a253c87c7de3b0 | Rust | Overmuse/datastore | /client/src/client.rs | UTF-8 | 2,140 | 2.984375 | 3 | [] | no_license | use crate::error::{Error, Result};
use crate::request::{Request, RequestBuilderExt};
use futures::prelude::*;
use reqwest::Client as ReqwestClient;
use std::borrow::Cow;
use std::env;
use std::sync::Arc;
#[derive(Clone)]
pub struct Client<'a> {
/// The underlying Reqwest client used for requests.
inner: Arc<Re... | true |
23a07692d084dd0b06ef598c7c82c593ccd4de09 | Rust | twe4ked/frog-beat | /src/system.rs | UTF-8 | 3,225 | 2.828125 | 3 | [] | no_license | use super::{Direction, Enemy, Player, Position, TilePosition, TILE_SIZE};
use coffee::graphics::{Color, Mesh, Rectangle, Shape};
use coffee::input::keyboard::KeyCode;
use coffee::input::KeyboardAndMouse;
use legion::query::filter::entity_data;
use legion::query::{IntoQuery, Query, Read, Write};
use legion::World;
pub ... | true |
613565ad50188144c4f8742ef6a710ce946dcf10 | Rust | L3afMe/serenity-utils-selfbot-support | /src/prompt.rs | UTF-8 | 1,493 | 3.59375 | 4 | [
"LicenseRef-scancode-unknown-license-reference",
"ISC"
] | permissive | //! Prompts to get user's response interactively.
//!
//! ## Examples
//!
//! This library provides two types of prompts: message-based and reaction-based.
//! An example for both is given below.
//!
//! ### Message Prompt
//!
//! ```
//! # use serenity::{
//! # model::prelude::{ChannelId, Message},
//! # prelude... | true |
ed83a587e78bedc526cfc8b09187bb39834c8ac3 | Rust | Saint-Vice/The-god-blessed | /LFPC/Parser/src/embded_lexer/tokenization.rs | UTF-8 | 2,185 | 3.828125 | 4 | [] | no_license | use std::fmt;
#[derive(Debug, PartialEq)]
pub enum Token {
Eof, Illegal,
Identifier(String),
Int(i64),
Plus, Increment, Minus, Decrement,
Assign, Asterisk, Slash, Exclamation,
Equal, NotEqual, LessThan, LessThanAndEqual,
MoreThan, MoreThanAndEqual,
Semicolon, Comma,
LeftParanthes... | true |
f34f8473679fe8487f244baa7df38c608dd6d8f2 | Rust | boundless-forest/elvis | /src/state.rs | UTF-8 | 746 | 3.0625 | 3 | [
"MIT"
] | permissive | use crate::{Error, FnBox};
use std::collections::HashMap;
type Hook<P> = Box<dyn FnBox<P>>;
/// state for tree
pub struct State<W, P> {
pub widget: W,
pub trigger: Hook<P>,
state: HashMap<String, String>,
}
impl<W, P> State<W, P> {
pub fn new(widget: W, trigger: Hook<P>) -> State<W, P> {
Stat... | true |
54e265014658c348f81ccf4957aae98b42bad3b1 | Rust | iCodeIN/rendertoy | /src/blob.rs | UTF-8 | 2,056 | 2.734375 | 3 | [
"MIT"
] | permissive | use super::package::get_cargo_package_dep_path;
use snoozy::*;
use std::fs::File;
use std::path::PathBuf;
#[derive(Hash, Debug)]
pub struct Blob {
pub contents: Vec<u8>,
}
#[snoozy]
pub async fn load_blob_snoozy(ctx: Context, path: &AssetPath) -> Result<Blob> {
ctx.set_debug_name(&path.asset_name);
let m... | true |
28035e931749a9cad15ca1237675af110bebacd3 | Rust | purpleposeidon/rust-x86asm | /gen_defs/src/instruction.rs | UTF-8 | 30,358 | 3.125 | 3 | [
"MIT"
] | permissive | use std::io::Write;
use ::{RegType};
use ::instruction_def::{InstructionDefinition, OperandType};
use ::operand::{Operand, OperandSize};
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Instruction {
pub mnemonic: String,
pub operand1: Option<Operand>,
pub operand2: Option<Operand>,
pub operand3: Opti... | true |
cc7625524b396369e5c949c6a00c28d186c49194 | Rust | kroeckx/ruma | /crates/ruma-appservice-api/src/query/query_room_alias/v1.rs | UTF-8 | 1,001 | 2.71875 | 3 | [
"MIT"
] | permissive | //! [GET /_matrix/app/v1/rooms/{roomAlias}](https://matrix.org/docs/spec/application_service/r0.1.2#get-matrix-app-v1-rooms-roomalias)
use ruma_api::ruma_api;
use ruma_identifiers::RoomAliasId;
ruma_api! {
metadata: {
description: "This endpoint is invoked by the homeserver on an application service to qu... | true |
849efebe4978c3e52ba8d4943cbd65abd46fe5cc | Rust | olaitanade/RustLang-Interview-Algorithms | /src/nth_fibonacci.rs | UTF-8 | 183 | 3.46875 | 3 | [] | no_license |
pub fn get_nth_fib(n:i64) -> i64{
if n == 2{
return 1;
}else if n == 1 {
return 0;
}else {
return get_nth_fib(n - 1) + get_nth_fib(n - 2);
}
} | true |
3a25f99ce095347325dc2b6b9b5feadd6c1f592a | Rust | xujihui1985/learningrust | /reusablecode/enumdemo/src/main.rs | UTF-8 | 1,694 | 3.328125 | 3 | [] | no_license | use std::ops::Add;
use std::cmp::PartialEq;
use hello_utils::utils::*;
use hello_utils::submod;
struct Point<T> {
x: T,
y: T,
}
impl<T> Point<T> {
fn get_x(&self) -> &T {
&self.x
}
}
fn largest<T>(list: &[T]) -> T
where T: PartialOrd + Copy {
let mut largest = list[0];
for &item ... | true |
874e0124fe79462f0e1bfd401caa7511661db632 | Rust | igncp/code-gym | /rust/advent_of_code_18/12/src/main.rs | UTF-8 | 16,232 | 3.234375 | 3 | [] | no_license | /*
--- Day 12: Subterranean Sustainability ---
The year 518 is significantly more underground than your history books implied. Either that, or
you've arrived in a vast cavern network under the North Pole.
After exploring a little, you discover a long tunnel that contains a row of small pots as far as
you can see to ... | true |
db336228c0bcf8b535056d6e4fa77734dd4f374d | Rust | TimurShaykhiev/gameboard | /src/cell.rs | UTF-8 | 7,858 | 3.546875 | 4 | [
"MIT"
] | permissive | //! Board cell.
use std::rc::Rc;
use unicode_segmentation::UnicodeSegmentation;
use termion::{style, cursor, color};
use crate::board::ResourceTable;
const RESOURCE_TABLE_ERR_MSG: &'static str =
"If you use Cell::ResourceId, you must add resource table to Board.";
/// Cell content.
#[derive(Clone)]
pub enum Ce... | true |
34fa2a29071247ab91dbbba9d9b87e33ebc2776d | Rust | nuta/archives | /resea2/libs/page_allocator/bitmap_allocator.rs | UTF-8 | 2,958 | 3.546875 | 4 | [] | no_license | use core::slice;
use etc::alignment::align_up;
use etc::bitmap::BitMap;
/// A physical memory page allocator.
///
/// This allocator tracks unused pages by a bitmap table at the very beginning of
/// the available memory space passed by [`BitMapAllocator::new`]: Once you allocate
/// a page, the corresponding bit is ... | true |
df59e6c8aa1d933bb165509efbe0bd28b12b4a3c | Rust | manuelmauro/google-code-jam | /Google-Code-Jam-2018/waffle-choppers/src/main.rs | UTF-8 | 4,633 | 3.234375 | 3 | [] | no_license | use std::io;
#[derive(Debug)]
struct Waffle {
r: usize,
c: usize,
h: usize,
v: usize,
data: Vec<Vec<usize>>,
diners_count: usize,
}
impl Waffle {
fn new(r: usize, c: usize, h: usize, v: usize, data: Vec<Vec<usize>>,) -> Self {
Waffle {
r,
c,
h,
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.