Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix clippy lints#1188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kczimm merged 4 commits intomasterfromkczimm-fix-clippy-lints
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionpgml-dashboard/build.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@ fn main() {
println!("cargo:rerun-if-changed=migrations");

let output = Command::new("git")
.args(&["rev-parse", "HEAD"])
.args(["rev-parse", "HEAD"])
.output()
.unwrap();
let git_hash = String::from_utf8(output.stdout).unwrap();
Expand Down
9 changes: 4 additions & 5 deletionspgml-dashboard/src/api/chatbot.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -298,10 +298,10 @@ pub async fn wrapped_chatbot_get_answer(
history.reverse();
let history = history.join("\n");

letmutpipeline = Pipeline::new("v1", None, None, None);
let pipeline = Pipeline::new("v1", None, None, None);
let context = collection
.query()
.vector_recall(&data.question, &mutpipeline, Some(json!({
.vector_recall(&data.question, &pipeline, Some(json!({
"instruction": "Represent the Wikipedia question for retrieving supporting documents: "
}).into()))
.limit(5)
Expand All@@ -312,9 +312,8 @@ pub async fn wrapped_chatbot_get_answer(
.collect::<Vec<String>>()
.join("\n");

let answer = match brain {
_ => get_openai_chatgpt_answer(knowledge_base, &history, &context, &data.question).await,
}?;
let answer =
get_openai_chatgpt_answer(knowledge_base, &history, &context, &data.question).await?;

let new_history_messages: Vec<pgml::types::Json> = vec![
serde_json::to_value(user_document).unwrap().into(),
Expand Down
42 changes: 21 additions & 21 deletionspgml-dashboard/src/api/cms.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,20 +88,20 @@ impl Collection {
fn build_index(&mut self, hide_root: bool) {
let summary_path = self.root_dir.join("SUMMARY.md");
let summary_contents = std::fs::read_to_string(&summary_path)
.expect(format!("Could not read summary: {summary_path:?}").as_str());
.unwrap_or_else(|_| panic!("Could not read summary: {summary_path:?}"));
let mdast = markdown::to_mdast(&summary_contents, &::markdown::ParseOptions::default())
.expect(format!("Could not parse summary: {summary_path:?}").as_str());
.unwrap_or_else(|_| panic!("Could not parse summary: {summary_path:?}"));

for node in mdast
.children()
.expect(format!("Summary has no content: {summary_path:?}").as_str())
.unwrap_or_else(|| panic!("Summary has no content: {summary_path:?}"))
.iter()
{
match node {
Node::List(list) => {
self.index = self.get_sub_links(&list).expect(
format!("Could not parse list of index links: {summary_path:?}").as_str(),
);
self.index = self.get_sub_links(list).unwrap_or_else(|_| {
panic!("Could not parse list of index links: {summary_path:?}")
});
break;
}
_ => {
Expand DownExpand Up@@ -221,13 +221,13 @@ impl Collection {
let root = parse_document(&arena, &contents, &crate::utils::markdown::options());

// Title of the document is the first (and typically only) <h1>
let title = crate::utils::markdown::get_title(&root).unwrap();
let toc_links = crate::utils::markdown::get_toc(&root).unwrap();
let image = crate::utils::markdown::get_image(&root);
crate::utils::markdown::wrap_tables(&root, &arena).unwrap();
let title = crate::utils::markdown::get_title(root).unwrap();
let toc_links = crate::utils::markdown::get_toc(root).unwrap();
let image = crate::utils::markdown::get_image(root);
crate::utils::markdown::wrap_tables(root, &arena).unwrap();

// MkDocs syntax support, e.g. tabs, notes, alerts, etc.
crate::utils::markdown::mkdocs(&root, &arena).unwrap();
crate::utils::markdown::mkdocs(root, &arena).unwrap();

// Style headings like we like them
let mut plugins = ComrakPlugins::default();
Expand DownExpand Up@@ -255,7 +255,7 @@ impl Collection {
.iter_mut()
.map(|nav_link| {
let mut nav_link = nav_link.clone();
nav_link.should_open(&path);
nav_link.should_open(path);
nav_link
})
.collect();
Expand All@@ -273,11 +273,11 @@ impl Collection {
let image_path = collection.url_root.join(".gitbook/assets").join(parts[1]);
layout.image(config::asset_url(image_path.to_string_lossy()).as_ref());
}
ifdescription.is_some() {
layout.description(&description.unwrap());
iflet Some(description) = &description {
layout.description(description);
}
ifuser.is_some() {
layout.user(&user.unwrap());
iflet Some(user) = &user {
layout.user(user);
}

let layout = layout
Expand DownExpand Up@@ -375,7 +375,7 @@ SELECT * FROM test;
"#;

let arena = Arena::new();
let root = parse_document(&arena,&code, &options());
let root = parse_document(&arena, code, &options());

// Style headings like we like them
let mut plugins = ComrakPlugins::default();
Expand DownExpand Up@@ -404,11 +404,11 @@ This is the end of the markdown
"#;

let arena = Arena::new();
let root = parse_document(&arena,&markdown, &options());
let root = parse_document(&arena, markdown, &options());

let plugins = ComrakPlugins::default();

crate::utils::markdown::wrap_tables(&root, &arena).unwrap();
crate::utils::markdown::wrap_tables(root, &arena).unwrap();

let mut html = vec![];
format_html_with_plugins(root, &options(), &mut html, &plugins).unwrap();
Expand DownExpand Up@@ -436,11 +436,11 @@ This is the end of the markdown
"#;

let arena = Arena::new();
let root = parse_document(&arena,&markdown, &options());
let root = parse_document(&arena, markdown, &options());

let plugins = ComrakPlugins::default();

crate::utils::markdown::wrap_tables(&root, &arena).unwrap();
crate::utils::markdown::wrap_tables(root, &arena).unwrap();

let mut html = vec![];
format_html_with_plugins(root, &options(), &mut html, &plugins).unwrap();
Expand Down
12 changes: 9 additions & 3 deletionspgml-dashboard/src/components/chatbot/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -41,7 +41,7 @@ const EXAMPLE_QUESTIONS: ExampleQuestions = [
),
];

const KNOWLEDGE_BASES: [&'staticstr; 0] = [
const KNOWLEDGE_BASES: [&str; 0] = [
// "Knowledge Base 1",
// "Knowledge Base 2",
// "Knowledge Base 3",
Expand DownExpand Up@@ -117,8 +117,8 @@ pub struct Chatbot {
knowledge_bases_with_logo: &'static [KnowledgeBaseWithLogo; 4],
}

impl Chatbot {
pubfnnew() ->Chatbot {
implDefault forChatbot {
fndefault() ->Self {
Chatbot {
brains: &CHATBOT_BRAINS,
example_questions: &EXAMPLE_QUESTIONS,
Expand All@@ -128,4 +128,10 @@ impl Chatbot {
}
}

impl Chatbot {
pub fn new() -> Self {
Self::default()
}
}

component!(Chatbot);
4 changes: 2 additions & 2 deletionspgml-dashboard/src/components/inputs/range_group/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,7 @@ impl RangeGroup {
pub fn new(title: &str) -> RangeGroup {
RangeGroup {
title: title.to_owned(),
identifier: title.replace(" ", "_").to_lowercase(),
identifier: title.replace(' ', "_").to_lowercase(),
min: 0,
max: 100,
step: 1.0,
Expand All@@ -42,7 +42,7 @@ impl RangeGroup {
}

pub fn identifier(mut self, identifier: &str) -> Self {
self.identifier = identifier.replace(" ", "_").to_owned();
self.identifier = identifier.replace(' ', "_").to_owned();
self
}

Expand Down
10 changes: 8 additions & 2 deletionspgml-dashboard/src/components/inputs/switch/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,8 +30,8 @@ pub struct Switch {
target: StimulusTarget,
}

impl Switch {
pubfnnew() ->Switch {
implDefault forSwitch {
fndefault() ->Self {
Switch {
left_value: String::from("left"),
left_icon: String::from(""),
Expand All@@ -42,6 +42,12 @@ impl Switch {
target: StimulusTarget::new(),
}
}
}

impl Switch {
pub fn new() -> Self {
Self::default()
}

pub fn left(mut self, value: &str, icon: &str) -> Switch {
self.left_value = value.into();
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,16 +35,22 @@ pub struct EditableHeader {
id: String,
}

impl EditableHeader {
pubfnnew() ->EditableHeader {
EditableHeader {
implDefault forEditableHeader {
fndefault() ->Self {
Self {
value: String::from("Title Goes Here"),
header_type: Headers::H3,
input_target: StimulusTarget::new(),
input_name: None,
id: String::from(""),
}
}
}

impl EditableHeader {
pub fn new() -> Self {
Self::default()
}

pub fn header_type(mut self, header_type: Headers) -> Self {
self.header_type = header_type;
Expand Down
1 change: 1 addition & 0 deletionspgml-dashboard/src/components/navigation/tabs/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,5 +6,6 @@ pub mod tab;
pub use tab::Tab;

// src/components/navigation/tabs/tabs
#[allow(clippy::module_inception)]
pub mod tabs;
pub use tabs::Tabs;
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,7 +37,7 @@ impl Tab {
}

pub fn id(&self) -> String {
format!("tab-{}", self.name.to_lowercase().replace(" ", "-"))
format!("tab-{}", self.name.to_lowercase().replace(' ', "-"))
}

pub fn selected(&self) -> String {
Expand Down
2 changes: 1 addition & 1 deletionpgml-dashboard/src/components/profile_icon/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,7 @@ pub struct ProfileIcon;

impl ProfileIcon {
pub fn new() -> ProfileIcon {
ProfileIcon::default()
ProfileIcon
}
}

Expand Down
2 changes: 1 addition & 1 deletionpgml-dashboard/src/components/star/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,7 @@ pub struct Star {
svg: &'static str,
}

const SVGS: Lazy<HashMap<&'static str, &'static str>> = Lazy::new(|| {
static SVGS: Lazy<HashMap<&'static str, &'static str>> = Lazy::new(|| {
let mut map = HashMap::new();
map.insert(
"green",
Expand Down
18 changes: 7 additions & 11 deletionspgml-dashboard/src/components/stimulus/stimulus_action/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,7 +38,7 @@ impl FromStr for StimulusEvents {
}
}

#[derive(Debug, Clone)]
#[derive(Debug,Default,Clone)]
pub struct StimulusAction {
pub controller: String,
pub method: String,
Expand All@@ -47,11 +47,7 @@ pub struct StimulusAction {

impl StimulusAction {
pub fn new() -> Self {
Self {
controller: String::new(),
method: String::new(),
action: None,
}
Self::default()
}

pub fn controller(mut self, controller: &str) -> Self {
Expand DownExpand Up@@ -81,8 +77,8 @@ impl fmt::Display for StimulusAction {

impl Render for StimulusAction {
fn render(&self, b: &mut Buffer) -> Result<(), sailfish::RenderError> {
if self.controller.len()== 0|| self.method.len() == 0 {
returnformat!("").render(b);
if self.controller.is_empty() || self.method.is_empty() {
returnString::new().render(b);
}
match &self.action {
Some(action) => format!("{}->{}#{}", action, self.controller, self.method).render(b),
Expand All@@ -95,12 +91,12 @@ impl FromStr for StimulusAction {
type Err = ();

fn from_str(input: &str) -> Result<Self, ()> {
let cleaned = input.replace(" ", "");
let cleaned = input.replace(' ', "");
let mut out: Vec<&str> = cleaned.split("->").collect();

match out.len() {
1 => {
let mut command: Vec<&str> = out.pop().unwrap().split("#").collect();
let mut command: Vec<&str> = out.pop().unwrap().split('#').collect();
match command.len() {
2 => Ok(StimulusAction::new()
.method(command.pop().unwrap())
Expand All@@ -110,7 +106,7 @@ impl FromStr for StimulusAction {
}
}
2 => {
let mut command: Vec<&str> = out.pop().unwrap().split("#").collect();
let mut command: Vec<&str> = out.pop().unwrap().split('#').collect();
match command.len() {
2 => Ok(StimulusAction::new()
.action(StimulusEvents::from_str(out.pop().unwrap()).unwrap())
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,7 +30,7 @@ impl Render for StimulusTarget {
(Some(controller), Some(name)) => {
format!("data-{}-target=\"{}\"", controller, name).render(b)
}
_ =>format!("").render(b),
_ =>String::new().render(b),
}
}
}
7 changes: 4 additions & 3 deletionspgml-dashboard/src/fairings.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,11 +9,12 @@ use crate::utils::datadog::timing;
/// Times requests and responses for reporting via datadog
struct RequestMonitorStart(std::time::Instant);

pub struct RequestMonitor {}
#[derive(Default)]
pub struct RequestMonitor;

impl RequestMonitor {
pub fn new() -> RequestMonitor {
RequestMonitor {}
Self
}
}

Expand DownExpand Up@@ -61,6 +62,6 @@ impl Fairing for RequestMonitor {
("path".to_string(), path.to_string()),
]);
let metric = "http.request";
timing(&metric, elapsed, Some(&tags)).await;
timing(metric, elapsed, Some(&tags)).await;
}
}
6 changes: 3 additions & 3 deletionspgml-dashboard/src/lib.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -80,7 +80,7 @@ pub async fn notebook_index(
) -> Result<ResponseOk, Error> {
Ok(ResponseOk(
templates::Notebooks {
notebooks: models::Notebook::all(&cluster.pool()).await?,
notebooks: models::Notebook::all(cluster.pool()).await?,
new: new.is_some(),
}
.render_once()
Expand DownExpand Up@@ -148,7 +148,7 @@ pub async fn cell_create(
.await?;

if !cell.contents.is_empty() {
let _ =cell.render(cluster.pool()).await?;
cell.render(cluster.pool()).await?;
}

Ok(Redirect::to(format!(
Expand DownExpand Up@@ -230,7 +230,7 @@ pub async fn cell_edit(
cell.update(
cluster.pool(),
data.cell_type.parse::<i32>()?,
&data.contents,
data.contents,
)
.await?;

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp