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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
df9228533afea93d262f9cfa816610836f052d9a | Rust | dmathieu/shellymetry | /src/shelly.rs | UTF-8 | 1,664 | 2.6875 | 3 | [
"MIT"
] | permissive | use opentelemetry::{
global,
trace::{Span, Tracer},
Context, Key,
};
use reqwest::Client;
use serde::Deserialize;
const URL_KEY: Key = Key::from_static_str("url");
#[derive(Debug, Deserialize)]
pub struct Meters {
pub power: f64,
}
#[derive(Debug, Deserialize)]
pub struct Shelly {
pub uptime: u64... | true |
98ac7adea29fd85f180bed0097d60aa46da99f59 | Rust | aswyk/oxidation | /oxidation/src/object/table.rs | UTF-8 | 2,502 | 3.171875 | 3 | [
"MIT"
] | permissive | // This code needs a lot of love...
//
use std::collections::HashMap;
use std::hash::{Hash, Hasher};
use config::TLuaNumber;
use object::values::Value;
#[derive(PartialEq,Eq,Debug,Clone)]
pub struct Table {
array_part: Vec<Value>,
hash_part: HashMap<Value, Value>
}
impl Table {
pub fn new() -... | true |
8ce6730ef2644fd7c4af945bd5bfeb913177fb53 | Rust | GrayChrysTea/brainfuck | /src/parser/mod.rs | UTF-8 | 818 | 3.09375 | 3 | [
"MIT"
] | permissive | //! [`brainfucklib::parser`]
//!
//! This module allows you to parse Brainfuck programs. There are 2 parsers
//! that you can use from this library. They are:
//! 1. [`nparser`], and
//! 2. [`sparser`]
//!
//! [`sparser`] is the simple parser. All it does is read all the characters
//! which represents Brainf... | true |
acda10e36b475d27d83343d86c76d39fb619239f | Rust | JoelWaterworth/liger | /src/compiler/mod.rs | UTF-8 | 9,757 | 2.671875 | 3 | [] | no_license | use type_checker::typed_ast::*;
use parsing::ast::BinaryOperator;
use std::fs::File;
use std::io::Write;
use std::io;
use compiler::code_generation::CodeGeneration;
mod code_generation;
mod llvm_node;
use std::process::Command;
use compiler::llvm_node::LLVMNode;
use std::path::Path;
pub fn compile(globals: Globals, ... | true |
bc2a45d9b53647885c80be9b64edb789e25e72f7 | Rust | AlterionX/totality-rs | /totality-model/src/scene.rs | UTF-8 | 557 | 2.625 | 3 | [] | no_license | use crate::{
Model,
geom::Geom,
};
use std::sync::Arc;
#[derive(Debug)]
pub struct Static {
pub objs: Vec<Arc<Box<dyn Geom>>>,
}
#[derive(Debug, Clone)]
pub struct Dynamic {
pub mm: Vec<Model>,
}
pub struct Scene(Static, Dynamic);
impl Scene {
pub fn new(gg: Vec<Arc<Box<dyn Geom>>>, mm: Vec<Model>... | true |
79c0f2909846338dccd28f341ae4cded4ada08fb | Rust | kmurf1999/CSE485PokerSolver | /poker_solver/src/codec.rs | UTF-8 | 2,162 | 3.328125 | 3 | [] | no_license | use crate::action::Action;
use crate::constants::*;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
/// Structure used send and receive game events to and from the server
/// encodes to json
pub enum PokerEvent {
/// Event sent to clients when game starts
GameStart,
/// Event ... | true |
0ef03ff2cdaf1ecb5e02ae1856beb2a3fe4703e5 | Rust | xuzhao9/rs-algo | /src/comb/test.rs | UTF-8 | 675 | 2.890625 | 3 | [] | no_license | use super::*;
const THRESHOLD: i32 = 11;
fn factorial(v: i32) -> i32 {
let mut r = 1;
for x in 1..v+1 {
r = r * x;
}
r
}
fn cal_permutation_len(m: i32, n: i32) -> i32 {
factorial(m) / factorial(m - n)
}
fn cal_combination_len(m: i32, n: i32) -> i32 {
factorial(m) / (factorial(m - n) * factorial(n))
... | true |
679da1f7974a0f57c1fefd71a3ae3a6e0c5e03fa | Rust | pretty-little-state-machine/AdventOfCode2019 | /src/day_01.rs | UTF-8 | 1,156 | 3.46875 | 3 | [
"MIT"
] | permissive | fn calc_module_fuel(mass: i64) -> i64 {
((mass as f64 / 3.0).floor() - 2.0) as i64
}
fn calc_all_fuel(mass: i64, total_mass: i64) -> i64 {
loop {
match calc_module_fuel(mass) {
f if f < 0 => return total_mass,
f if f >= 0 => return calc_all_fuel(f, total_mass + f),
_... | true |
63c13328fff858ae2816cb3f30605d2371d19888 | Rust | denoland/deno_lint | /src/rules/triple_slash_reference.rs | UTF-8 | 3,404 | 2.765625 | 3 | [
"MIT"
] | permissive | // Copyright 2020-2021 the Deno authors. All rights reserved. MIT license.
use super::{Context, LintRule};
use deno_ast::swc::common::comments::Comment;
use deno_ast::swc::common::comments::CommentKind;
use deno_ast::SourceRange;
use deno_ast::SourceRangedForSpanned;
use derive_more::Display;
use once_cell::sync::Lazy... | true |
936796e60f8dddac2524093af9bc0d402778666f | Rust | shua/ascii-box-editor | /src/parse.rs | UTF-8 | 11,858 | 3.390625 | 3 | [] | no_license | use std::collections::HashSet;
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct Point {
pub row: usize,
pub col: usize,
}
#[derive(Clone, Copy, PartialEq, Eq)]
pub struct TBox(pub Point, pub Point);
pub struct Lines(pub Vec<Vec<char>>);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Direction {... | true |
81034f0377564e787a769bce6cbf7102616469dc | Rust | koshkin-na/algorithm-examples | /src/bin/find_max_subarr.rs | UTF-8 | 1,673 | 3.21875 | 3 | [] | no_license | use rand::Rng;
use simplelog::{Config, SimpleLogger};
use std::time::Duration;
use cpu_time::ProcessTime;
const SIZE_ARRAY: usize = 15;
fn main() {
let _ = SimpleLogger::init(log::LevelFilter::Info, Config::default());
log::info!("An example of a find max subarray implementation");
let mut arr: Vec<i32> =... | true |
d9b45bf7000ef1fdc89d2f35c72a1f08567234f5 | Rust | AldaronLau/zstandard | /src/lib.rs | UTF-8 | 15,200 | 2.84375 | 3 | [] | no_license | //! ZStandard compression format encoder and decoder implemented in pure Rust
//! without unsafe.
// Reference: https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#frame_header
#![doc(
html_logo_url = "https://raw.githubusercontent.com/facebook/zstd/dev/doc/images/zstd_logo86.png",
html_f... | true |
35276498f965ed25edf51d11cb92a6c5eb62d0fe | Rust | incker2/logram | /src/source/fs/event.rs | UTF-8 | 1,256 | 3.0625 | 3 | [
"MIT"
] | permissive | use std::path::PathBuf;
use crate::source::LogRecord;
#[derive(Debug)]
pub enum FsEvent {
Created { path: PathBuf },
Writed { path: PathBuf, new_content: String },
Removed { path: PathBuf },
Renamed { from: PathBuf, to: PathBuf },
}
impl FsEvent {
pub fn into_record(self) -> LogRecord {
l... | true |
ab7f7915732bb3dabd1ffdc45447f35957b7d31f | Rust | gtank/zebra | /zebrad/src/commands/start.rs | UTF-8 | 2,101 | 2.71875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! `start` subcommand - example of how to write a subcommand
/// App-local prelude includes `app_reader()`/`app_writer()`/`app_config()`
/// accessors along with logging macros. Customize as you see fit.
use crate::prelude::*;
use crate::config::ZebradConfig;
use abscissa_core::{config, Command, FrameworkError, Opt... | true |
b60f64580163dc11d806eb04b98dbbe46faa266d | Rust | commieprincess/aoc2017 | /day_17/src/main.rs | UTF-8 | 708 | 3.078125 | 3 | [] | no_license | fn main() {
let input : usize = include_str!("input.txt").trim().parse().unwrap();
let mut buffer : Vec<u32> = vec![0];
let mut position : usize = 0;
let mut last_insertion_index = 0;
for i in 1..2018 {
position = (position + input) % buffer.len();
buffer.insert(position + 1, i);
... | true |
3672cb6032d2a8bb27ba7ec9497ccc39a045aa49 | Rust | jarod/rust-assimp | /src/ffi/cimport.rs | UTF-8 | 10,599 | 2.875 | 3 | [
"MIT"
] | permissive | use libc::{c_char, c_uint, c_float, c_int};
use scene::RawScene;
use types::{AiString, MemoryInfo};
use fileio::{AiFileIO};
/// Represents an opaque set of settings to be used during importing.
#[repr(C)]
pub struct PropertyStore {
sentinel: c_char,
}
#[link(name = "assimp")]
extern {
/// Reads the given fi... | true |
f0f1b48b72f4769879149432e3d5ebea9022803f | Rust | reinvantveer/advent-of-code-2020 | /day_10/src/main.rs | UTF-8 | 8,372 | 2.796875 | 3 | [
"MIT"
] | permissive | use std::fs;
use petgraph::graph::{DiGraph, NodeIndex};
use petgraph::visit::EdgeRef;
use std::collections::HashMap;
fn main() {
let lines = read_lines("input.txt");
let adapters = lines_to_numbers(&lines);
let chain = get_adapter_chain(&adapters);
let (diffs_1_jolt, diffs_3_jolt) = get_joltage_differe... | true |
c2853ab9d36fb13daff49ced2781983b22ab2ccd | Rust | lawrencecrane/adventofcode2020 | /day16/src/lib.rs | UTF-8 | 3,061 | 3.46875 | 3 | [] | no_license | use std::collections::HashMap;
pub fn calculate_error_rate(data: &TicketData) -> usize {
data.nearby
.iter()
.map(|ticket| {
ticket
.iter()
.filter(|field| !is_valid(*field, &data.rules))
.sum::<usize>()
})
.sum()
}
fn is_... | true |
7e78f12557bf446f88be4039e2364adf71effad1 | Rust | iqlusioninc/yubihsm.rs | /tests/integration.rs | UTF-8 | 5,075 | 2.578125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! Integration tests (using live YubiHSM 2 or MockHsm)
use once_cell::sync::Lazy;
use std::sync::{Mutex, MutexGuard};
use yubihsm::{asymmetric, device, object, Capability, Client, Connector, Domain};
/// Integration tests for individual YubiHSM 2 commands
mod command;
/// ECDSA tests
mod ecdsa;
/// Ed25519 tests
m... | true |
61c035ee0b50f50e497595726baf425f26139b37 | Rust | dangdennis/data-structures-and-algorithms-in-rust | /src/sliding_window_maximum.rs | UTF-8 | 1,879 | 3.71875 | 4 | [] | no_license | use std::collections::VecDeque;
// Given an array nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window.
// Input: nums = [1,3,-1... | true |
94af27b27debbaf5b53f369124b53a513678104b | Rust | StardustOS/stardust_db | /src/lib.rs | UTF-8 | 2,299 | 2.75 | 3 | [] | no_license | use std::path::Path;
use ast::ColumnName;
pub use c_interface::*;
use data_types::Value;
use error::{ExecutionError, Result};
use interpreter::Interpreter;
use query_process::process_query;
use relation::Relation;
use resolved_expression::ResolvedColumn;
use sqlparser::{dialect::GenericDialect, parser::Parser};
mod a... | true |
4ca1ee4220072dd239f358041da174d2961986dc | Rust | johnstonskj/rust-xml_dom | /src/level2/node_impl.rs | UTF-8 | 12,734 | 2.703125 | 3 | [
"MIT"
] | permissive | use crate::level2::ext::ProcessingOptions;
use crate::level2::ext::XmlDecl;
use crate::level2::traits::{Node, NodeType};
use crate::level2::{get_implementation, DOMImplementation};
use crate::shared::name::Name;
use crate::shared::rc_cell::{RcRefCell, WeakRefCell};
use std::collections::HashMap;
use std::fmt::{Debug, F... | true |
987088079a02e4d54b7cfe07c32f1a635a2137cf | Rust | jzohdi/rustaceans | /oop/src/main.rs | UTF-8 | 1,587 | 3.71875 | 4 | [] | no_license | //use oop::Post;
fn main() {
let mut post = Post::new();
post.add_text("Learning rust is hard");
post.add_text("\nIt's really fun though!");
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
pub fn test_empty() {
let mut post = Post::new();
post.add_text("Hello world");
... | true |
06dc9a1ab8000b493bc645534a0d553eb2ec6f0f | Rust | snsvrno/lprun-rs | /lprun/src/core.rs | UTF-8 | 927 | 2.859375 | 3 | [
"MIT"
] | permissive | use platform_lp::Platform;
use version_lp::Version;
use failure::Error;
use std::path::{Path,PathBuf};
use binary;
pub fn run<P : AsRef<Path>>(plat : &Platform, ver : &Version, package_path : Option<P>) -> Result<(),Error> {
//! runs love based on a ***platform*** and a ***version***
//!
//! ... | true |
4a139d6026696049a9f2a3ab4e6bb52cd6762587 | Rust | tbehner/seeking-trouble | /src/code_repository.rs | UTF-8 | 11,202 | 2.921875 | 3 | [] | no_license | use regex::Regex;
use git2::{Repository,Oid, DiffDelta, DiffHunk, DiffLine};
use thiserror::Error;
use std::collections::HashMap;
use crate::change_set::ChangeSet;
use std::path::{Path,PathBuf};
#[derive(Error, Debug)]
pub enum CodeRepositoryError {
#[error("data store disconnected")]
Open(#[from] git2::Error... | true |
038796e49b14198951fb68ac316f34c402afd2b2 | Rust | ZcashFoundation/zebra | /zebra-chain/src/diagnostic/task/future.rs | UTF-8 | 3,173 | 3.203125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | //! Diagnostic types and functions for Zebra async future tasks:
//! - task handles
//! - errors and panics
use std::{future, panic};
use futures::future::{BoxFuture, FutureExt};
use tokio::task::{JoinError, JoinHandle};
use crate::shutdown::is_shutting_down;
use super::{CheckForPanics, WaitForPanics};
/// This is... | true |
db8e4c2e73cea89eb88c422f9d2a1c7613f6454a | Rust | robbycerantola/orbgame | /src/event.rs | UTF-8 | 1,683 | 2.9375 | 3 | [
"MIT"
] | permissive | use std::cell::{Cell, RefCell};
use orbtk::Rect;
#[derive(Clone, Debug, Deserialize, PartialEq)]
pub enum EventCondition {
Enter
}
impl Default for EventCondition {
fn default() -> Self {
EventCondition::Enter
}
}
#[derive(Clone, Debug, Deserialize)]
pub enum EventAction {
None,
SwitchSc... | true |
d60c2a41c4091941b03a43ed41bc11d1daf57b66 | Rust | mripard/doremi | /examples/kmsv.rs | UTF-8 | 3,944 | 2.53125 | 3 | [
"MIT"
] | permissive | extern crate clap;
extern crate doremi;
extern crate fixed;
extern crate image;
use std::cmp::min;
use std::convert::TryInto;
use std::thread;
use std::time;
use clap::App;
use clap::Arg;
use fixed::types::extra::U16;
use fixed::FixedU32;
use image::GenericImageView;
use doremi::Buffer;
use doremi::BufferType;
use d... | true |
2b287486f39c141f04a9dc990bbe9dee824cc7c9 | Rust | bergwolf/kata-containers | /src/tools/log-parser-rs/src/log_message.rs | UTF-8 | 17,038 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) 2023 Gabe Venberg
//
// SPDX-License-Identifier: Apache-2.0
use std::{fmt::Debug, fmt::Display, str::FromStr};
use chrono::{DateTime, Utc};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_with::{
serde_as, skip_serializing_none, DeserializeFromStr, DisplayFromStr, SerializeDi... | true |
95d6346680aff366ebd3a05bf90248fc7464a2eb | Rust | Webrow/valheim-docker | /src/commands/stop.rs | UTF-8 | 1,124 | 2.59375 | 3 | [] | no_license | use crate::utils::{get_working_dir, server_installed};
use log::{info, error, debug};
use clap::ArgMatches;
use crate::files::server_pid::is_running;
use std::thread::sleep;
use std::time::Duration;
use crate::files::server_exit::stop_server;
pub fn invoke(args: &ArgMatches) {
let paths = &[get_working_dir(), "ser... | true |
f71949f8ac8684289cfe2d15a4d7394d9e1a866a | Rust | fschutt/dbusmenu-rs | /src/menu.rs | UTF-8 | 10,064 | 3.109375 | 3 | [
"MIT"
] | permissive | //! Menu abstrction module
use std::collections::HashMap;
use std::rc::Rc;
use std::cell::RefCell;
use dbusmenu::ComCanonicalDbusmenu;
use dbus::arg;
use dbus;
#[derive(Default)]
pub struct Menu {
/// - `revision: i32`: The revision number of the layout.
/// For matching with layoutUpdated signals.
revis... | true |
9331f9a50cdb7eaf1f2a31e9dd9831e999629c13 | Rust | bartsmykla/codewars | /src/katas/k6_prize_draw.rs | UTF-8 | 4,022 | 3.40625 | 3 | [
"MIT"
] | permissive | #![allow(unused)]
/*
Kata: https://www.codewars.com/kata/prize-draw/train/rust
To participate in a prize draw each one gives his/her firstname.
Each letter of a firstname has a value which is its rank in
the English alphabet. A and a have rank 1, B and b rank 2 and so on.
The length of the first... | true |
c7a417ecfa1e329d774ede9c5ff209c9e387bc96 | Rust | hygt/aoc2018 | /src/bin/day14a.rs | UTF-8 | 653 | 3.078125 | 3 | [
"Unlicense"
] | permissive | use std::char;
fn main() {
let mut recipes = vec![3, 7];
let mut i: usize = 0;
let mut j: usize = 1;
let input = 768071;
while recipes.len() < 10 + input {
let sum = recipes[i] + recipes[j];
if sum < 10 {
recipes.push(sum);
} else {
recipes.push(1);... | true |
13d141fa840805ece581376baef2d677c9d897ee | Rust | eranfu/ray_tracing | /src/aabb.rs | UTF-8 | 991 | 2.96875 | 3 | [] | no_license | use crate::*;
use core::mem;
#[derive(Copy, Clone)]
pub struct AABB {
min: Vector3,
max: Vector3,
}
impl AABB {
pub fn new(min: Vector3, max: Vector3) -> AABB {
AABB { min, max }
}
pub fn min(&self) -> &Vector3 {
&self.min
}
pub fn surrounding(&self, other: &AABB) -> AABB... | true |
509281be3d514924d2714626971b09b108c69c45 | Rust | kartevonmorgen/opening-hours-rs | /src/tests/time_selector.rs | UTF-8 | 1,574 | 2.59375 | 3 | [] | no_license | use crate::parser::Error;
use crate::schedule_at;
use crate::time_domain::RuleKind::*;
#[test]
fn basic_timespan() -> Result<(), Error> {
assert_eq!(
schedule_at!("14:00-19:00", "2020-06-01"),
schedule! { 14,00 => Open => 19,00 }
);
assert_eq!(
schedule_at!("10:00-12:00,14:00-16:00... | true |
0e72fe56b36727f39b681c6fe232c0a4ca2909c2 | Rust | ksakiyama/practice_atcoder | /abc051c/src/main.rs | UTF-8 | 1,419 | 2.96875 | 3 | [] | no_license | fn main() {
let vec = read_line();
// 0 0 1 2
let sx : i32 = vec[0];
let sy : i32 = vec[1];
let tx : i32 = vec[2];
let ty : i32 = vec[3];
// 1 s-->t
// 2 t-->s
{
// go ahead
let h = (sy - ty).abs();
let w = (sx - tx).abs();
for _ in 0..h {
... | true |
38b39fdcea3dfdea397e0c53c0e91bd5592c19f7 | Rust | brandon-chow/crustydb | /src/utilities/src/serverwrapper.rs | UTF-8 | 3,612 | 3.03125 | 3 | [] | no_license | use escargot::CargoBuild;
use std::io::{Read, Result, Write};
use std::net::{Shutdown, TcpStream};
use std::process::{Child, Stdio};
pub struct ServerWrapper {
stream: TcpStream,
child: Child,
}
impl ServerWrapper {
fn setup_server() -> Result<Child> {
CargoBuild::new()
.bin("server")
... | true |
b224b85b0e80aa5956d87df6034af23408d4023f | Rust | staktrace/rust_tinyget | /src/lib.rs | UTF-8 | 4,390 | 3.8125 | 4 | [
"MIT",
"ISC"
] | permissive | //! # tinyget
//! Simple, minimal-dependency HTTP client.
//! The library has a very minimal API, so you'll probably know
//! everything you need to after reading a few examples.
//!
//! # Additional features
//!
//! Since the crate is supposed to be minimal in terms of
//! dependencies, there are no default features, ... | true |
ef774457cd43e8e83ab2b7b7cf257bda45834cfd | Rust | mgdm/med | /src/cursor.rs | UTF-8 | 1,504 | 3.15625 | 3 | [] | no_license | use std::io;
use std::io::prelude::*;
use std::io::{ Stdin, StdinLock, Stdout, StdoutLock };
use stdio::Stdio;
static POSITION_REPORT: &'static str = "\x1b[6n\r\n";
static SHOW_CURSOR: &'static str = "\x1b[?25h";
static HIDE_CURSOR: &'static str = "\x1b[?25l";
pub struct Cursor {
x: usize,
y: usize,
x_li... | true |
a36336feb883dbeb0ffefcc9db0a61821f8e6530 | Rust | dotxlem/wasmer | /lib/deprecated/runtime-core/doc/new-api/exports.rs | UTF-8 | 213 | 2.578125 | 3 | [
"MIT"
] | permissive | struct Exports {}
impl Exports {
fn get<'a, T: Exportable<'a> + Clone + 'a>(&'a self, name: &str) -> Result<T, ExportError>;
fn iter(&self) -> ExportsIterator<impl Iterator<Item = (&String, &Export)>>;
}
| true |
a22a5fc8a9dd2d38e17f25a69532c2a077b5a1bc | Rust | zxt1996/Practice-once-a-day | /LeetCode-Rust/136.只出现一次的数字/one.rs | UTF-8 | 447 | 3.1875 | 3 | [] | no_license | use std::collections::HashMap;
impl Solution {
pub fn single_number(nums: Vec<i32>) -> i32 {
let mut map = HashMap::new();
for i in nums.iter() {
if map.contains_key(i) {
map.insert(i, 2);
} else {
map.insert(i, 1);
}
}
... | true |
a27f0a238ae8842184a5793907bde6f080a7612b | Rust | TheRawMeatball/sky-sl | /crates/sky-sl/src/workspace/mod.rs | UTF-8 | 2,956 | 2.71875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use camino::{Utf8Path, Utf8PathBuf};
use crate::db::{CompilerDatabase, SourceDatabase, SyntaxDatabase};
use crate::syn::{Parse, cst::LineIndex, ast::Root};
use std::sync::{Arc, Mutex};
mod fs;
mod error;
mod package;
pub use error::*;
pub use package::*;
struct Inner {
root: Utf8PathBuf,
manifest: Utf8PathB... | true |
64c841933c236155a69e9b55e16414db5a20995a | Rust | lucafanselau/city-builder | /crates/gfx/src/heapy.rs | UTF-8 | 9,322 | 2.71875 | 3 | [] | no_license | use crate::memory_page::MemoryPage;
use generational_arena::{Arena, Index};
use gfx_hal::{
adapter::PhysicalDevice,
device::Device,
memory::{Properties, Requirements},
Backend, MemoryTypeId,
};
use parking_lot::RwLock;
use render::resource::buffer::MemoryType;
use std::ops::Deref;
use std::sync::atomic:... | true |
be6e9847d855f8bee8de518dc171ed4ac2bba893 | Rust | zmbush/traffic-sim | /src/scenario.rs | UTF-8 | 8,449 | 2.96875 | 3 | [
"MIT"
] | permissive | use std::fmt::{self, Debug};
use sfml::system::Vector2f;
use sfml::graphics::{RenderTarget, RectangleShape, CircleShape, Color};
use sfml::traits::Drawable;
use rand::{thread_rng, Rng};
use std::f32;
#[derive(Debug, Clone, Copy)]
struct Waypoint {
location: Vector2f,
speed: f32,
}
impl Waypoint {
fn new(l... | true |
1826afd1d28b1bdb84d88fcb87ed31404b5f0400 | Rust | dgc-network/dgc-database-TP | /processor/src/addressing.rs | UTF-8 | 1,858 | 2.5625 | 3 | [
"Apache-2.0",
"CC-BY-4.0"
] | permissive | // Copyright (c) The dgc.network
// SPDX-License-Identifier: Apache-2.0
use crypto::digest::Digest;
use crypto::sha2::Sha512;
const FAMILY_NAME: &str = "dgc_REST_api";
const PARTICIPANT: &str = "ae";
const PROPERTY: &str = "ea";
const PROPOSAL: &str = "aa";
const RECORD: &str = "ec";
const TABLE: &str = "ee";
const E... | true |
ba542798fbb0316db579c204f3e6af63a336de7b | Rust | kimsk/try-rust | /concepts/iterator/basic/src/array_iterators.rs | UTF-8 | 1,192 | 3.328125 | 3 | [] | no_license | #[derive(Debug)]
pub struct ForwardArrayIterator {
current_index: usize,
array: [i32;5]
}
impl ForwardArrayIterator {
pub fn new(array: [i32;5]) -> ForwardArrayIterator {
ForwardArrayIterator {
current_index: 0,
array
}
}
}
impl Iterator for ForwardArrayIterator... | true |
849a0e81dd6ba03da823ce97953858351dd544d0 | Rust | saibatizoku/herder | /src/mastodon.rs | UTF-8 | 2,080 | 2.9375 | 3 | [
"MIT"
] | permissive | //! This module contains the code representing Mastodon nodes and API Clients
//!
use Client;
use api::oauth::{CreateApp, OAuthApp};
use errors::*;
use hyper::header::Bearer;
use serde_json;
use std::str::FromStr;
use std::sync::{Arc, Mutex};
use url::Url;
/// `Mastodon` is used to specify the base url of a Mastodon n... | true |
5c533ee71b880d4852249854050aa0ff22ac285e | Rust | nicholastmosher/emjc | /src/emj_grammar.rs | UTF-8 | 16,937 | 2.625 | 3 | [] | no_license | use lexer::TokenType;
use parser::{
NonTerminal,
Production,
ProductionTable,
};
// FIRST(P) = FIRST(M) = { class }
// P -> M C' $
// FIRST(M) = { class }
// FOLLOW(M) = FIRST(C') - { epsilon } = { class }
// M -> class I { public static void main ( String [ ] I ) { S } }
// FIRST(C) = { class }
// FOLLO... | true |
d166cdf4b9a1406c394fcd98ea59f7f306c971c3 | Rust | cfeitong/cft-leveldb | /src/encoding.rs | UTF-8 | 3,974 | 3.171875 | 3 | [] | no_license | use bytes::{
Buf,
BufMut,
Bytes,
};
pub trait BufMutExt: BufMut {
fn put_var_u32_le(&mut self, n: u32);
fn put_var_u64_le(&mut self, n: u64);
}
const B: u8 = 1 << 7;
impl<T: BufMut> BufMutExt for T {
fn put_var_u32_le(&mut self, n: u32) {
match n {
x if x < (1 << 7) => {
... | true |
9b0492a0935125acde3feae2a18f9ea48dfddfed | Rust | kczimm/advent-of-code-2020 | /src/day9/main.rs | UTF-8 | 1,996 | 3.640625 | 4 | [
"MIT"
] | permissive | use input;
use std::io::Result;
use std::collections::VecDeque;
fn main() -> Result<()> {
let content = input::load_file("src/day9/input.txt")?;
let preamble_size = 25;
let num = first_number(&content, preamble_size);
println!("part1: {}", num);
println!("part2: {}", sum_contiguous(&content, num... | true |
45efcc02fd5cb2df1a640f49c7d9a4035d8e7c7c | Rust | yspace/begin_rust | /src/the_book/structs/define_instantiate.rs | UTF-8 | 2,292 | 3.671875 | 4 | [
"MIT"
] | permissive | struct User{
username: String,
email: String,
sign_in_count: u64,
active: bool ,
}
fn build_user(email: String, username: String) -> User{
// 有默认值
User{
email: email,
username: username,
active: true,
sign_in_count: 1,
}
}
fn build_user2(email: String, usern... | true |
6e4ad820369808f65c69e1e9dae24a769ab96194 | Rust | Luca-Girotti/project-euler-solutions | /problems_01-10/problem_09/src/main.rs | UTF-8 | 463 | 3.125 | 3 | [] | no_license | // Special Pythagorean triplet
// https://projecteuler.net/problem=9
fn main() {
let (mut _a, mut _b, mut _c): (u32, u32, u32) = (0, 0, 0);
let mut m: u32 = 2;
'a: loop {
for n in 1..m {
_a = m * m - n * n;
_b = 2 * m * n;
_c = m * m + n * n;
if _a... | true |
b9ff942685a47d99d6432f74c6cf94e3d880f4bf | Rust | Valink16/conway_gol | /gol/src/grid.rs | UTF-8 | 3,766 | 3.515625 | 4 | [] | no_license | use std::convert::TryInto;
use crate::neigh;
use rand;
// A grid representing the plane where the simulation takes place
// The data is stored as a 1D array of booleans, since each cell can only be either dead or alive
// The outer rim of the grid should be never evaluated to reduce program complexity, calling get_... | true |
e62dc1bea7291a1815f5cba66262c565c7a5ba0c | Rust | rectinajh/rust-leetcode | /src/l0086_partition_list.rs | UTF-8 | 1,503 | 3.640625 | 4 | [] | no_license | /*
给定一个链表和一个特定值 x,对链表进行分隔,使得所有小于 x 的节点都在大于或等于 x 的节点之前。
你应当保留两个分区中每个节点的初始相对位置。
示例:
输入: head = 1->4->3->2->5->2, x = 3
输出: 1->2->2->4->3->5
*/
use crate::share::ListNode;
struct Solution {}
impl Solution {
pub fn partition(head: Option<Box<ListNode>>, x: i32) -> Option<Box<ListNode>> {
//小于x的
let m... | true |
5d85052659086a9fec8318e2ab1bff876ab79dff | Rust | 71/styx-history | /styx.rs/src/opt.rs | UTF-8 | 1,925 | 3.640625 | 4 | [
"MIT"
] | permissive | //! [`Optimization`] level, and related [`OptimizationOptions`].
/// Represents a set of options that define how a function and its dependencies should be optimized.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct OptimizationOptions {
/// How many recursive calls can be made to compute a value during compilati... | true |
25ea522e296a74dbbead625792c2e238e17695df | Rust | tcr3dr/dronekit-rust | /src/vehicle.rs | UTF-8 | 14,772 | 2.734375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | extern crate mio;
extern crate bit_vec;
use mavlink::*;
use std::collections::HashMap;
use std::iter::repeat;
use std::cell::RefCell;
use std::rc::Rc;
use eventual::Future;
use bit_vec::BitVec;
use connection::{VehicleConnection, parse_mavlink_string};
pub enum VehicleMode {
LOITER,
GUIDED,
}
#[derive(Clon... | true |
62303d34c9cb91fec1269c923e2def0c84bac155 | Rust | procyon-rs/showata | /src/show_ndarray.rs | UTF-8 | 2,087 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed... | true |
2275d4dd45fe462d4105c462a629e44e4d7b5ed9 | Rust | SymmetricChaos/classic_crypto | /src/codes/binary/ascii.rs | UTF-8 | 2,446 | 3.046875 | 3 | [] | no_license | use std::{collections::HashMap};
use lazy_static::lazy_static;
use crate::codes::binary::code_generators::FixedWidthInteger;
use crate::alphabets::ASCII128;
lazy_static! {
pub static ref ASCII_MAP8: HashMap<char, String> = {
let mut m = HashMap::new();
let codes = FixedWidthInteger::new(8);
... | true |
8c559a323a272f33f02c651907b6d74144145e93 | Rust | zatchl/kawaiifi | /src/wifi_protocol.rs | UTF-8 | 3,512 | 2.96875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::{
ies::{DataRate, SupportedRates},
Ie,
};
use derive_more::{
BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Deref, DerefMut, From, Not,
};
use enumflags2::{bitflags, BitFlags};
use std::fmt::Display;
#[bitflags]
#[derive(Copy, Clone, Debug, PartialEq, Ord, PartialOrd, Eq)]
#[rep... | true |
c9a3175cc22b1f6bf0acd8c9cfe18030e3cfe288 | Rust | EthanMalin/wrent | /src/draw/core.rs | UTF-8 | 2,590 | 2.921875 | 3 | [] | no_license | extern crate image;
use crate::geometry;
use crate::geometry::{Vec2, Vec3};
use crate::imgutil::Image;
// --- types
pub type ColorRGB = [u8; 3];
// --- functions
// bresenham's
pub fn line_points(mut x1: i32, mut y1: i32, mut x2: i32, mut y2: i32, img: &mut Image, color: ColorRGB) {
let mut steep = false;
// if ... | true |
17a3d1f1cd0664679b6f4d7ab0d7a8123bf66417 | Rust | fabienheureux/engine | /src/systems/player.rs | UTF-8 | 1,578 | 2.546875 | 3 | [] | no_license | use crate::GameState;
use crate::{
components::{Player as PlayerComponent, RigidBody, Transform},
ecs::{Entity, System, World},
};
use glutin::VirtualKeyCode;
use nalgebra as na;
use nalgebra_glm as glm;
use na::{geometry::Translation};
use std::any::TypeId;
#[derive(Debug, Default)]
pub struct Player;
impl S... | true |
9e6fd169f0dd2d67665768c00d7526aeab6ccde9 | Rust | ipetkov/conch-parser | /src/ast/builder/empty_builder.rs | UTF-8 | 3,732 | 2.890625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::ast::builder::*;
use crate::ast::{AndOr, RedirectOrCmdWord, RedirectOrEnvVar};
use void::Void;
/// A no-op `Builder` which ignores all inputs and always returns `()`.
///
/// Useful for validation of correct programs (i.e. parsing input without
/// caring about the actual AST representations).
#[derive(Debu... | true |
0278036900aa7e4240dda7afed2a65087c66d651 | Rust | ganmacs/leveldb-rs | /examples/test.rs | UTF-8 | 751 | 2.6875 | 3 | [
"MIT"
] | permissive | extern crate leveldb;
fn main() {
let mut db = leveldb::open("level");
// db.set("key0", "value0");
// db.set("key1", "value1");
// db.set("key2", "value2");
// db.set("key3", "value3");
println!("{:?}", db.get("key0"));
println!("{:?}", db.get("key1"));
println!("{:?}", db.get("key2")... | true |
353fa7374b68ed94e02fe5a5675c8557d63a0f6f | Rust | ichihara-3/practice | /rust/hello-rust/src/main.rs | UTF-8 | 199 | 3.359375 | 3 | [] | no_license |
struct Point {
x: i32,
y: i32,
}
fn get_point() -> Point {
return Point {
x: 0,
y: 0,
};
}
fn main() {
let p = get_point();
println!("{} {}", p.x, p.y);
}
| true |
ee4b8dc7dfbaec785f12299ffc8a8e5d7aca6400 | Rust | RobJenks/simulated-annealing-optimisation | /src/system/results.rs | UTF-8 | 745 | 2.84375 | 3 | [] | no_license | use std::cmp::Ordering;
use crate::system::state::State;
use crate::solver::result::SolverResult;
use crate::system::solvable::Solvable;
pub struct Results<TState>
where TState: State {
solver_results: Vec<SolverResult<TState>>
}
impl <TState> Results<TState>
where TState: State {
pub fn new(results... | true |
eee83e87e5dfdffe9733be8b8fa5b013396e372d | Rust | meilier/rust-error-handle | /src/demo_06_02_custom_error.rs | UTF-8 | 2,162 | 3.359375 | 3 | [
"MIT"
] | permissive | use std::io::Error as IoError;
use std::str::Utf8Error;
use std::num::ParseIntError;
use std::fmt::{Display, Formatter};
///读取文件内容
fn read_file(path: &str) -> std::result::Result<String, std::io::Error> {
std::fs::read_to_string(path)
}
/// 转换为utf8内容
fn to_utf8(v: &[u8]) -> std::result::Result<&str, std::str::Utf... | true |
04dbb3c234ccde5644fd865ef97d6b2bdda91633 | Rust | cmk/icfpc2018 | /wata/src/destruction/util.rs | UTF-8 | 880 | 2.71875 | 3 | [
"MIT"
] | permissive | use super::super::{V3, P};
pub fn get_filled_positions(filled: &V3<bool>) -> Vec<P> {
let r = filled.len();
let mut ps = vec![];
for x in 0..r {
for y in 0..r {
for z in 0..r {
let p = P::new(x as i32, y as i32, z as i32);
if filled[p] {
... | true |
6f5b06f01030e022664dc8e90e73fb5874a99f8b | Rust | securycore/prefetchkit | /src/formatter.rs | UTF-8 | 6,705 | 2.546875 | 3 | [
"WTFPL"
] | permissive | // DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// Version 2, December 2004
//
// Copyright (C) 2018 Thomas Bailleux <thomas@bailleux.me>
//
// Everyone is permitted to copy and distribute verbatim or modified
// copies of this license document, and changing it is allowed as long
// as the... | true |
3f8d00ffb01bda95dd75f9f47edcd9e79a7382cd | Rust | rsaarelm/morlock-hunter | /src/calx/app.rs | UTF-8 | 4,840 | 2.71875 | 3 | [
"MIT"
] | permissive | use std::default::Default;
use color::RGB;
use color::rgb::{ToRGB};
use cgmath::aabb::{Aabb, Aabb2};
use cgmath::vector::{Vec2};
use cgmath::point::{Point, Point2};
use stb::image::Image;
use rectutil::RectUtil;
use color::rgb::consts::*;
use renderer;
use renderer::{Renderer};
use gen_id::CodeId;
use tile::Tile;
use t... | true |
623935df4cb876f51fed23ba3e13d6fc00c56e05 | Rust | jslupicki/solteq-demo-app | /rust-backend/src/adhoc_tests.rs | UTF-8 | 2,578 | 2.90625 | 3 | [] | no_license | use actix_http::http::Method;
use actix_web::{test, App};
use crate::commons_for_tests;
use crate::main_tests::login_as_admin;
#[actix_rt::test]
async fn check_login_guard() {
setup_test!("check_login_guard");
let mut app = test::init_service(App::new().configure(|cfg| rest::config_all(cfg))).await;
let ... | true |
f76227fdb4c59214fd6b292e95726d80bc0dafce | Rust | redmar/aoc2020 | /day13/src/main.rs | UTF-8 | 1,639 | 2.875 | 3 | [] | no_license | fn main() {
// part 1
let input = include_str!("../input.txt");
let mut lines = input.lines();
let min_depart = lines.next().unwrap().parse::<u32>().unwrap();
let bus_ids: Vec<u32> = lines
.next()
.unwrap()
.split(",")
.filter_map(|item| item.parse::<u32>().ok())
... | true |
5797c2ddc7ed24a7108a9d0ee930df6fe9d5cdd5 | Rust | stainless-steel/assert | /src/lib.rs | UTF-8 | 1,069 | 3.625 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | //! Assertions for testing.
mod traits;
pub use traits::{Float, Floats};
/// Assert that the absolute difference between two quantities is small.
///
/// In case of vectors, the assertion is elementwise.
pub fn close<F, F1, F2>(x: F1, y: F2, delta: F)
where
F: Float,
F1: Floats<F>,
F2: Floats<F>,
{
le... | true |
27555819e6b3093bc378eb1c1fc7d59afa2eb936 | Rust | shakyShane/wf2 | /wf2_core/src/cli/mod.rs | UTF-8 | 4,518 | 2.640625 | 3 | [] | no_license | use crate::cli::cli_input::DEFAULT_CONFIG_FILE;
use crate::cli::error::CLIError;
use crate::context::Context;
use crate::recipes::recipe_kinds::RecipeKinds;
use clap::{App, AppSettings, Arg};
use std::str::FromStr;
pub mod cli_input;
pub mod cli_output;
pub mod error;
pub struct CLI<'a, 'b> {
pub app: clap::App<'... | true |
73c7fb326634460008aa757181763a71a9e845a7 | Rust | MCord/gitui | /src/ui/scrolllist.rs | UTF-8 | 1,175 | 3.21875 | 3 | [
"MIT"
] | permissive | use std::iter::Iterator;
use tui::{
buffer::Buffer,
layout::Rect,
style::Style,
widgets::{Block, List, Text, Widget},
};
///
pub struct ScrollableList<'b, L>
where
L: Iterator<Item = Text<'b>>,
{
block: Option<Block<'b>>,
/// Items to be displayed
items: L,
/// Index of the scroll p... | true |
406f8fdbd6557f50c23819d1f71f5b7c8c81e03d | Rust | jackyzhen/learn-rust | /ownership/src/main.rs | UTF-8 | 264 | 3.4375 | 3 | [] | no_license | fn main() {
let s1 = give_ownership();
let s2 = s1;
let _s3 = takes_and_gives_ownership(s2);
}
fn give_ownership() -> String {
let some_string = String::from("Hello");
some_string
}
fn takes_and_gives_ownership(s: String) -> String {
s
}
| true |
c1f4d6b6484534c73d1f161bb91a8fe3129ea5c5 | Rust | danieldulaney/portable-shortcuts-rs | /src/main.rs | UTF-8 | 1,647 | 2.96875 | 3 | [] | no_license | #[macro_use]
extern crate serde_derive;
extern crate toml;
use std::collections::HashMap;
use std::fs::{self, File};
use std::io::prelude::*;
use std::path::Path;
use std::env;
const CONFIG_FILENAME: &str = "assets/config.toml";
#[derive(Debug, Deserialize)]
struct Config {
shortcuts: HashMap<String, Shortcut>,
... | true |
a245736407e39bb8eaf813e4381835f1947b2ba9 | Rust | OliLay/smaRSt-fan | /src/main.rs | UTF-8 | 2,262 | 2.546875 | 3 | [
"MIT"
] | permissive | pub mod config;
pub mod control;
pub mod logging;
pub mod mqtt;
pub mod sensing;
pub mod signals;
use crate::config::Config;
use control::pid::PidControl;
use control::pwm::PwmControl;
use log::{info, trace, warn};
use logging::initialize_logging;
use mqtt::MqttClient;
use parking_lot::Mutex;
use sensing::cpu_temp::Cp... | true |
61cdb2bb0166dc3d72c047324dc2b85df3e5a4e8 | Rust | rjw245/ee194_final_proj | /benchmarks/matrixMult/rust/src/matrixMultiply_old.rs | UTF-8 | 1,486 | 2.9375 | 3 | [] | no_license | //Concurrency modules
use std::sync::Arc;
use std::thread;
use std::thread::JoinHandle;
const TOTAL_SIZE: usize = 16;
const NTHREADS: usize = 1;
fn main(){
let mut thread_list: Vec<JoinHandle<i64>> = Vec::new();
let mut a : Vec<Vec<f32>> = Vec::new();
let mut b : Vec<Vec<f32>> = Vec::new... | true |
8b0478ef7b48f0403ab71417ec00d0d3b685d88e | Rust | sogapalag/contest | /atcoder/arc069/e.rs | UTF-8 | 1,669 | 2.984375 | 3 | [] | no_license | #[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
#[allow(dead_code)]
fn getline() -> String {
let mut ret = String::new();
std::io::stdin().read_line(&mut ret).ok();
return ret;
}
fn get_word() -> String {
let mut stdin = std::io::stdin();
l... | true |
ee4f6f3232be92c48f85165f6b76930fe3e50664 | Rust | sampsyo/bril | /bril-rs/src/program.rs | UTF-8 | 21,952 | 2.953125 | 3 | [
"MIT"
] | permissive | use std::{
fmt::{self, Display, Formatter},
hash::Hash,
};
use serde::{Deserialize, Serialize};
/// Equivalent to a file of bril code
#[cfg_attr(not(feature = "float"), derive(Eq))]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub struct Program {
/// A list of functions declared in the prog... | true |
90b790d8aa17690b962c52ad3ef5b2035cbd92a1 | Rust | steinemann/xshell | /src/gsl.rs | UTF-8 | 5,048 | 3.5625 | 4 | [
"Apache-2.0",
"MIT"
] | permissive | //! Global shell lock.
use std::{
cell::Cell,
sync::{RwLockReadGuard, RwLockWriteGuard},
};
/// If, on the same thread, there are multiple calls to [`read`] or [`write`],
/// then the `Guard`s returned should be dropped in the reverse order that they
/// were acquired.
///
/// If this is violated, e.g. in
///... | true |
53e7bbcbbb70b5a50cc85924ee3433f028da0c3b | Rust | fable-compiler/Fable | /src/fable-library-rust/src/HashSet.rs | UTF-8 | 2,219 | 3.1875 | 3 | [
"MIT"
] | permissive | pub mod HashSet_ {
// -----------------------------------------------------------
// HashSets
// -----------------------------------------------------------
#[cfg(feature = "no_std")]
use hashbrown as collections;
#[cfg(not(feature = "no_std"))]
use std::collections;
use crate::Native... | true |
5177cb1cbee9c7a45d53525f74209d4e9830dc65 | Rust | ckomaki/kaggle-santa-2017-winner-solution | /src/rust/input.rs | UTF-8 | 6,589 | 2.78125 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufRead, BufReader};
use std::collections::{HashMap, HashSet};
pub struct ScoreEdge {
pub sink: usize,
pub lscore: i32,
pub rscore: i32,
}
impl ScoreEdge {
pub fn get_lscore(&self) -> i32 {
self.lscore
}
pub fn get_rscore(&self) -> i32 {
self.... | true |
d821c90afa3c559e777e08855d3e347d341970a9 | Rust | Johan-Mi/persimmon | /ui/src/widgets/text.rs | UTF-8 | 908 | 2.921875 | 3 | [
"Unlicense"
] | permissive | use crate::core::{Rect, UiResponse, Widget};
use sdl2::{pixels::Color, rect::Rect as SdlRect};
pub struct Text {
pub text: String,
pub style: TextStyle,
}
impl Widget for Text {
fn handle_event(
&mut self,
_event: &sdl2::event::Event,
) -> Option<UiResponse> {
None
}
f... | true |
bb15a36c7433a8b39db4951092b2f660b1c14980 | Rust | southball/rust-cms | /src/server/routes/not_found.rs | UTF-8 | 382 | 2.53125 | 3 | [] | no_license | use crate::server::State;
use tide::{Request, Response, Result, StatusCode};
pub async fn not_found(mut req: Request<State>) -> Result {
crate::server::templates::render_template(
&req,
"error.liquid",
&liquid::object!({
"title": "404 Not Found",
"body": "Page not fo... | true |
2b60a2383194debd8bac9b7e5dd9d90b75737e3c | Rust | LukeMathWalker/clustering-benchmarks | /rust-grpc/src/server.rs | UTF-8 | 1,882 | 2.5625 | 3 | [] | no_license | use super::Store;
use ndarray::Array;
use tonic::{Request, Response, Status, Code};
pub mod centroids {
// The string specified here must match the protos package name
tonic::include_proto!("ml");
}
use centroids::{server::ClusteringService,
PredictRequest, PredictResponse,
PredictBatchRequest, Predi... | true |
34eb78a46211e733fcf5e63ffecbd99eb100ff2d | Rust | BafDyce/adventofcode | /2017/rust/day17/src/part2.rs | UTF-8 | 501 | 2.90625 | 3 | [
"Unlicense"
] | permissive | pub fn solve(input: usize) -> usize {
let mut idx = 0usize;
let mut idx0 = 0;
let mut val_after_0 = 1;
let mut val_at_idx_0 = 0;
for ii in 1..50_000_001 {
idx = (idx + input + 1) % ii;
if idx == idx0 {
val_after_0 = ii;
}
if idx == 0 {
val_... | true |
8cc8722c53c42b7ac950bd69ad363bbfe62178f4 | Rust | utilForever/BOJ | /Rust/12852 - Make to 1 2.rs | UTF-8 | 1,898 | 3.53125 | 4 | [
"MIT"
] | permissive | use std::io;
fn input_integers() -> Vec<i32> {
let mut s = String::new();
io::stdin().read_line(&mut s).unwrap();
let values: Vec<i32> = s
.as_mut_str()
.split_whitespace()
.map(|s| s.parse().unwrap())
.collect();
values
}
fn main() {
let n = input_integers()[0] ... | true |
f4c77f47014f90b25ef3468547d503db0a11c864 | Rust | sunli829/yql | /libs/core/src/expr/funcs/nulls.rs | UTF-8 | 8,139 | 3.03125 | 3 | [] | no_license | use std::sync::Arc;
use crate::array::{
ArrayExt, BooleanType, DataType, Float32Type, Float64Type, Int16Type, Int32Type, Int64Type,
Int8Type, NullArray, PrimitiveArray, PrimitiveBuilder, StringArray, StringBuilder,
TimestampType,
};
use crate::expr::func::{Function, FunctionType};
use crate::expr::signatur... | true |
cd70d99c8296fab8e38f09019a9c24315f65c74c | Rust | notdanilo/gpu | /src/data/framebuffer.rs | UTF-8 | 3,778 | 3.359375 | 3 | [] | no_license | use crate::data::Image2D;
use crate::data::Renderbuffer;
use crate::{Context, GLContext};
type FramebufferResource = u32;
enum FramebufferAttachment {
Image(Image2D),
Renderbuffer(Renderbuffer),
None
}
/// A Framebuffer representation with optional `color`, `depth` and `stencil` attachments.
pub struct ... | true |
1f5decd428e343ec4edd4f2de1937b65cd33d303 | Rust | skade/strand | /tests/mutable.rs | UTF-8 | 2,945 | 3.375 | 3 | [
"MIT"
] | permissive | extern crate strand;
#[cfg(test)]
mod tests {
use strand::mutable::Event;
use strand::mutable::Strand;
use strand::branchable::Branchable;
use strand::strand::{Mutable};
use strand::strand;
use strand::errors::{Errors};
#[derive(Copy,Clone)]
struct Value {
x: i32
}
#[derive(Copy,Clone)]
str... | true |
a30286836af8a96286645e03a73412ff5e8669bc | Rust | mathieu-keller/rust_kata | /potter/src/main.rs | UTF-8 | 3,012 | 3.796875 | 4 | [] | no_license | use std::collections::HashMap;
const BOOK_ID_ARRAY: [u8; 5] = [1, 2, 3, 4, 5];
const BOOK_PRICE: u16 = 800;
fn main() {
print!("{}", buy(&[1, 1, 2, 3, 4, 3, 5, 2]));
}
fn buy(book_ids: &[u8]) -> f32 {
let mut books = map_books(book_ids);
let mut overall_price = 0;
while !books.is_empty() {
le... | true |
04165e7387977790be4e3d2542c35edfe42447af | Rust | internetimagery/ambisonic | /src/bstream.rs | UTF-8 | 8,858 | 2.984375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Represent audio sources in *B-format*.
use crate::bformat::{Bformat, Bweights};
use crate::constants::SPEED_OF_SOUND;
use rodio::Source;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use std::time::Duration;
/// Convert a `rodio::Source` to a spatial `Bstream` source with associated ... | true |
9865fcae2dc6dfdc1c89e3babbcacfcebe255551 | Rust | notomo/kiview | /src/src/command/unknown.rs | UTF-8 | 370 | 2.515625 | 3 | [] | no_license | use super::command::CommandResult;
use crate::command::Command;
use crate::command::ErrorKind;
pub struct UnknownCommand<'a> {
pub command_name: &'a str,
}
impl<'a> Command for UnknownCommand<'a> {
fn actions(&self) -> CommandResult {
Err(ErrorKind::Unknown {
command_name: self.command_nam... | true |
fd3fb962d19b918f039f3e8cd81fa76b9969c69f | Rust | brunocodutra/reducer | /src/reducer/rc.rs | UTF-8 | 2,444 | 3.4375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::reducer::*;
use alloc::rc::Rc;
/// Enhances a potentially _unsized_ [`Reducer`] with copy-on-write semantics (requires [`alloc`]).
///
/// Helps avoiding cloning the entire state when it needs to be sent to other parts of the
/// application.
///
/// [`alloc`]: index.html#optional-features
///
/// # Example... | true |
e0dd2855758c997fad474d8d2ad03808ec6e50e5 | Rust | agerasev/ringbuf | /src/tests/skip.rs | UTF-8 | 1,683 | 3.21875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use super::Rb;
use crate::{storage::Static, traits::*};
use alloc::rc::Rc;
#[test]
fn skip() {
// Initialize ringbuffer, prod and cons
let mut rb = Rb::<Static<i8, 10>>::default();
let (mut prod, mut cons) = rb.split_ref();
let mut i = 0;
// Fill the buffer
for _ in 0..10 {
prod.try_pu... | true |
6d9e78b62059f8b9380f281b07d508f3b62f1549 | Rust | swerdloj/jitter | /src/frontend/parse/mod.rs | UTF-8 | 56,023 | 2.96875 | 3 | [
"BSD-3-Clause"
] | permissive | pub mod ast;
use crate::Span;
use ast::{Literal, Node};
use super::lex::{self, Token, SpannedToken, Keyword};
use crate::frontend::validate::types::Type;
use std::collections::HashMap;
// TODO: Return Results from everything.
// TODO: Handle errors by simply return the expected node, but poisoned.
// Then, pr... | true |
646810b6b9fdf207476a20270dc63b4a88a44a54 | Rust | lnicola/fasteval | /src/ez.rs | UTF-8 | 1,990 | 3.46875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! An easy API for single-function-call expression evaluation.
use crate::error::Error;
use crate::parser::Parser;
use crate::evaler::Evaler;
use crate::slab::Slab;
use crate::evalns::EvalNamespace;
/// The `ez_eval()` function provides a very simple way to perform expression evaluation with just one function call.
... | true |
19b328b9e95d346d9ec5bba7e6357dc3a7d28e0f | Rust | gcapell/aoc2019 | /aoc2/src/main.rs | UTF-8 | 1,804 | 3.109375 | 3 | [] | no_license | use std::fs::read_to_string;
fn main() {
let s = filename_to_nums("input2.txt").unwrap();
// part1(&s);
part2(&s);
}
fn part2(s: &[u64]) {
for noun in 0..=99 {
for verb in 0..=99 {
if run(&s, noun, verb) == 19690720 {
println!("noun:{}, verb:{} want:{}", noun, verb,... | true |
e6701f7a5db117055ebdae2c108241ee7f914fc9 | Rust | andymac-2/advent-of-code | /2019/src/day15.rs | UTF-8 | 3,938 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::HashMap;
use std::convert::{TryFrom, TryInto};
use ncurses as nc;
use crate::day05::Machine;
use crate::day11::{Direction, Point};
enum Cell {
Empty,
Wall,
Cylinder,
}
impl TryFrom<i64> for Cell {
type Error = ();
fn try_from(raw: i64) -> Result<Self, ()> {
match raw... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.